Well, the way Windows does it is to return a value indicating the things are
in progress. Presumably, you'd also have a means for the UI thread to join
the actual data processing thread (you'll be using threads, if you want two
things, the UI and the process, to run at once), when it's time, as well as
some means of checking status or reporting progress. As for how you decide
that you've waited too long and should fork the remaining processing off
into a thread, that's going to be a custom thing. You'll probably do
something like this:
UI Thread
-----------
int StartPotentiallyLongProcess()
{
Create thread to do the process.
Wait for thread exit for some period of time, 1 second, say.
If Wait returned time-out, the process is going to be a while, so return
WORKING_ON_IT
If Wait returned an indication that the thread was done, return DONE
}
Paul T.
[quoted text, click to view] "Sean" <nospam@sbcglobal.com> wrote in message
news:LVwGe.2548$kk6.2467@newssvr13.news.prodigy.com...
>I probably not using the right terminology. Sorry ... I probably should
>just state it as a synchronized function call (vs. async)
>
> When the method is called, it is not returned until data is processed
> completely. I need to find a way to return the "wait-too-long" error to
> the appl, such that the appl can show the error to users or take other
> approaches, etc.
>
> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
> wrote in message news:ukMUf5HlFHA.3256@TK2MSFTNGP12.phx.gbl...
>> What is it blocking *on*? Every case will be broken in a different way,
>> for cleanest exit.
>>
>> Paul T.
>>
>> "Sean" <nospam@sbcglobal.com> wrote in message
>> news:TiwGe.2522$kk6.2196@newssvr13.news.prodigy.com...
>>> Hi,
>>>
>>> Need some suggestions:
>>>
>>> What is the best way to interrupt a blocking function call? I have a
>>> synchronized method which might take a long time to complete, and the
>>> time to complete the work is really depending on network condition and
>>> the server workload. I want to give users a way to break it up instead
>>> of waiting for the WaitCursor forever.
>>>
>>> trying to have anothe thread throw an exception and hoping the othe
>>> thread can catch it to beak it up. I found the other thread is not
>>> catching the exception thrown by other thread. Does it make sense? Am
>>> I still able to make it this way? Or other alternative to achieve the
>>> same objective?
>>>
>>> Thanks in advance.
>>> Sean
>>>
>>
>>
>
>