Threading

Here you will find tutorials that will help you with programming.

Threading

Postby Johnny5 » Mon Nov 24, 2008 5:04 pm


Hi everyone,

When developing .net programs you sometimes run into problems with freezing, this happens when the application loaded too much. Therefore, you have to run on a separate thread. Here is a little example in VB.NET.

Public Class Settings
Private worker As System.Threading.Thread

Private Sub Settings_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

'SaveSettings() 'This is regular way, which will froze your app.
worker = New Threading.Thread(New Threading.ThreadStart(AddressOf Me.SaveSettings))
worker.Name = "Save Settings"
worker.Start()

End Sub

Private Sub SaveSettings()
'Do your saving here, which run on a different thread

End Sub

End Class

Hopes this will help solve some of your freezing problems.

Happy Programming!
Johnny5
imFiles Junior
imFiles Junior
 
Posts: 72
Joined: Wed Dec 29, 2004 7:16 pm

Re: Threading

Postby String » Mon Nov 24, 2008 5:49 pm

Nice example. Thanks
String
imFiles Senior
imFiles Senior
 
Posts: 282
Joined: Mon Mar 10, 2008 7:06 am


Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests