Friday, July 27, 2012

Use of Background Worker, Error Provider

Have you ever experienced "Not Responding" message in your software applications, when you start some process ??? What do you think the reason for it ??? It's simply because the .NET Framework, all interaction with the user interface (UI) must be performed on a single thread, often referred to as the UI thread. The UI thread is the only thread that can update the UI or respond to events that the UI raises. So when a busy process is running the UI keeps freezing until the current process completes. The best solution to avoid this situation is to use a Background Worker.

The BackgroundWorker class enables you to run code on another thread. The BackgroundWorker class includes events that indicate the progress of the thread. A UI can subscribe to these events and update the screen by using the UI thread. This enables you to build a UI that remains responsive and up to date.
Download the sample from the  following link and you'll be able to get some knowledge on,
  • Simple usage of Background Worker
  • Usage of Error Provider in .Net framework
  • Simple Linq to Sql
  • Some coding standards 
Development Environment : MS Visual studio 2010, Sql Server 2005 or above

NOTE :  Before running the sample application modify the "app.config" file in the "StudentManagementSystem.Service" project with the connection string of your database.


2 comments:

  1. Nice example Darshana.. It's great you would add worker process cancellation & reporting progress to the same.

    Keep it up...:)

    ReplyDelete
    Replies
    1. Yes, sure, I'll look forward to add them as well. Any way thanks a lot for the comment.

      Delete