PC Review


Reply
Thread Tools Rate Thread

BackgroundWorker inside a user defined function

 
 
Torben Laursen
Guest
Posts: n/a
 
      13th Mar 2007
I have a Excel COM written in C# that has a number of user defined
functions. (UDF)
Some of them take a long time (5-10 minuts) to complete so I would like to
run them code inside a thread so it does not lock Excel and the user can
stop them it if he wants.
I have a backgroundworker inside a class (calcthread) and call it like this
inside the UDF
calcthread.Execute(Mixture, ModuleInfo); ///starts the thread

while(calcthread.IsBusy) ///waite for the thread to finish by checking
IsBusy in the backgroundworker, so the UDF can return the result

{


}

///Code to return the result.

The problem that I have is that the while code makes the code hang.

The thread finish inside the event DoWork but the event RunWorkerCompleted
is never called.

If I remove the while code RunWorkerComplete is called but then I dont know
how to make the UDF return the results when the thread is done.

The problem seems my call to IsBusy.

Can anyone tell me how to solve this problem?



Thanks Torben


 
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
HELP: CLR Trigger Fails when inside a user defined transaction! Leon_Amirreza Microsoft ADO .NET 0 14th Jul 2007 01:19 PM
Excel - User Defined Function Error: This function takes no argume =?Utf-8?B?QnJ1Y2VJbkNhbGdhcnk=?= Microsoft Excel Programming 3 23rd Aug 2006 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. korrin.anderson@gmail.com Microsoft Excel Programming 0 20th Jun 2006 03:53 PM
Determine the current cell while inside a User Defined Function pmax Microsoft Excel Programming 2 1st Feb 2006 11:47 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Microsoft Excel Programming 1 6th Aug 2003 09:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:00 AM.