Skip to content

Threading

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #190289
    Johnny5
    Member

    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!

    #190290
    String
    Member

    Nice example. Thanks

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.