PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

background worker cancel problem

 
 
Smokey Grindel
Guest
Posts: n/a
 
      7th Jan 2008
I have a search function that runs in a background worker which can run
long.. I want the user to be able to cancel that then run another search...
but sometimes it throws an exception saying

System.InvalidOperationException: This BackgroundWorker is currently busy
and cannot run multiple tasks concurrently.

What I did before the search button was pressed again was check if the
worker is busy and if it is cancel the current search then start another...
now how can i make sure the worker isnt workering before trying to start
another? Even though I cancelled the work some work might still be
processing before it realizes its cancelled and thats what seems to be
causing the error... thanks!


 
Reply With Quote
 
 
 
 
Ryan Jones
Guest
Posts: n/a
 
      16th Jan 2011
You might be able to use a loop to look the current thread until you background worker is finished:

While MyBackgroundWorker.IsBusy

End While

> On Monday, January 07, 2008 3:37 PM Smokey Grindel wrote:


> I have a search function that runs in a background worker which can run
> long.. I want the user to be able to cancel that then run another search...
> but sometimes it throws an exception saying
>
> System.InvalidOperationException: This BackgroundWorker is currently busy
> and cannot run multiple tasks concurrently.
>
> What I did before the search button was pressed again was check if the
> worker is busy and if it is cancel the current search then start another...
> now how can i make sure the worker isnt workering before trying to start
> another? Even though I cancelled the work some work might still be
> processing before it realizes its cancelled and thats what seems to be
> causing the error... thanks!



> Submitted via EggHeadCafe
> ASP.NET Base64 Image Encoding via the Data: protocol
> http://www.eggheadcafe.com/tutorials...-protocol.aspx

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cancel Background worker in multi tier environment parez Microsoft C# .NET 11 5th Jun 2008 07:44 PM
Background Worker Cross Thread UI problem Jerry Spence1 Microsoft VB .NET 7 12th Mar 2008 10:01 AM
How to create multiple instances of a worker object on a worker th =?Utf-8?B?RXJpayBKZW5zZW4=?= Microsoft Dot NET Framework 0 1st Nov 2005 04:37 AM
I can map all files (.*) to asp.net worker.How do I map NO FILE to asp.net worker? alex Microsoft ASP .NET 1 4th Feb 2005 04:18 AM
Reading form properties on a background worker thread. =?Utf-8?B?R3Jhdnk=?= Microsoft Dot NET Framework Forms 2 16th Nov 2004 03:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:24 PM.