Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default BackgroundWorker inside a user defined function

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. [email protected] Excel Programming 0 June 20th 06 03:53 PM
Determine the current cell while inside a User Defined Function pmax Excel Programming 2 February 1st 06 11:47 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"