all groups > dotnet compact framework > july 2005 >
You're in the

dotnet compact framework

group:

interrupt a blocking call


Re: interrupt a blocking call Paul G. Tobey [eMVP]
7/29/2005 1:44:59 PM
dotnet compact framework:
What is it blocking *on*? Every case will be broken in a different way, for
cleanest exit.

Paul T.

[quoted text, click to view]

Re: interrupt a blocking call Paul G. Tobey [eMVP]
7/29/2005 2:22:58 PM
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]

Re: interrupt a blocking call Steve Maillet (eMVP)
7/29/2005 5:27:43 PM
You still didn't answer the question so let me try phrasing it a different
way:

Given (pseudo code):

void BlockingFunc(...)
{
DoSomeProcessing();
WaitForSomethingToHappen();
DoSomeMoreProcessing();
}

What does YOUR code do in place of WaitForSomethingToHappen() this will
determine the appropriate mechanism for doing timeouts. (There are many
different possibilities each with it's own unique solution so you need to
provide that info before anyone can be of any real help).

--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com

interrupt a blocking call Sean
7/29/2005 8:27:31 PM
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

Re: interrupt a blocking call Sean
7/29/2005 9:08:59 PM
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>
[quoted text, click to view]

Re: interrupt a blocking call Sean
8/1/2005 6:57:42 PM
The "DoSomeProcessing" invoke a webservice to a remote transaction service,
which probably get blocked in the backend for some unknown reason to me.

The "WaitForSomethingToHappen" pretty much only show users the status of the
remote transaction status, if the webservice function call returns.

I want to improve user experience is by adding some code "DoSomeMoreProcess"
such that it tell users, "Server is busy, try again or adandon?".

The suggest I got from Paul works. I am still open for more oppinions to
learn more.

Best Regards,
Sean

[quoted text, click to view]

AddThis Social Bookmark Button