Results 1 to 3 of 3

Thread: [2005]what the equivalent suspending in backgroundworker

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2005
    Location
    UK
    Posts
    87

    [2005]what the equivalent suspending in backgroundworker

    Hi

    in Thread I can use suspend/resume event. what the equivalent in backgroundworker component?

    thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005]what the equivalent suspending in backgroundworker

    It is bad practice to arbitrarily suspend threads and Microsoft has deprecated the Suspend and Resume methods with the intention of removing them in future versions. That means that you should NOT be using them at all in any new code. if you want to suspend a thread then you should set a variable that indicates it is so. The thread being suspended can then test that variable at points at which it is safe to be suspended and then do so itself. A BackgroundWorker is just a friendly wrapper around a thread, so you can do the same thing. You simply set a variable that indicates that you want to pause the background operation and when it is safe to do so the methods called from the DoWork event handler can test that variable and pause the current thread if necessary.

    Pausing and Resuming Threads
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2005
    Location
    UK
    Posts
    87

    Re: [2005]what the equivalent suspending in backgroundworker

    Hi. Thanks for reply.
    What should I write in dowork to pause it? It is my first time use this component

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width