Wednesday, March 03, 2010

C# tips: Multi-threading with BackgroundWorker Component

Now I found a simpler way of doing multi-threading programming in C#: using the Backgroundworker component.

For it to work properly, you must make sure that "any" interaction with UI (controls on your Windows form) must be done at the "ProgressChanged" event handler of your BackgroundWorker component.

The following is a summary of the things you need to do for using the backgroundworker component:

(1) Add the backgroundworker component to your form
(2) Set the "WorkerReportsProgress" property of the backgroundworker to True
(3) Set the "WorkerSupportsCancellation" property of the backgroundworker to True
(4) Create the event handler of the backgroundworker for "DoWork", "ProgressChanged" and "RunWorkerCompleted"
(5) Put in the statements or procedures to be executed by the backgroundworker inside the event handler of "DoWork". This should be the starting point of the thread-processing. This event will be fired when you execute the statement such as

backgroundWorker1.RunWorkerAsync();

The sample codes can be found here
Reference in MSDN

Visual C# 2008 Express and Ms SQL Server 2005 Express

I have been playing around with Visual C# 2008 Express, ASP.NET and Ms SQL Server 2005 Express edition for a few months lately ... just for the sake of gaining back some interests and good memories of programming ... :)

Basically, for those who likes programming can download the .NET Framework 3.5 free and you can also download the IDE (Integrated Development Environment) such as Visual C# 2008 Express and Visual Studio 2008 Express for web development free too. Another interesting thing is you can even download and install Ms SQL Server 2005 express edition free too! But, after you install the Ms SQL 2005 express edition, you need to also download the SQL Server Management Studio client for the UI-based creation of database and stored procedures.

However, when you get real with product development then you can buy the necessary licenses for proper support and additional things you need.

For further information, try this :)

Converting a Physical Linux to Virtual

Hmm ... I have done a lot of work on my Linux Lubuntu 15.10 with PHP and PostgreSQL and a few other things ... it is quite time-consuming to...