I start a BackGroundWorke r to populate a grid. It is started off in
the ui layer
The thread follows( cannot think of a better word) the path
UI->Layer1->Layer2->Communicatio n Layer
and it blocks (the server is executing somthing where which takes
time)
How do i cancel this background worker?
Is there anyway i can access the thread object used by the
backgroundworke r and then stop it?
if i can is there anything wroong with it?
TIA
Jun 27 '08
16 2441
On Jun 3, 7:24 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Tue, 03 Jun 2008 15:13:55 -0700, parez <psaw...@gmail. comwrote:
The
only advantage I would get by using async reads is ability to close
the
socket.
Coz there is nothing else i need to do between BeginRead and EndRead
(other than may be checking the flag)
I don't see how the async/sync API affects this. Even if you used the
sync API, but called it from a thread, you could close the Stream (or
Socket...whatev er it is you're actually using) and an exception would be
thrown, terminating the operation.
1)
If I use sync api, I would be blocking on the read hence not able to
close the socket.
That's not true. You can't close the socket from the thread that's
blocking, but that's trivially obvious and not relevant. You can close
the socket from whatever thread needs to interrupt the thread that's
blocking. A blocking read can be interrupted just as easily as a
non-blocking read.
Pete
So how can i cancel the blocked read? Should i raise and handle a
RequestCancelle d Event?
On Wed, 04 Jun 2008 06:24:43 -0700, parez <ps*****@gmail. comwrote:
1)
If I use sync api, I would be blocking on the read hence not able to
close the socket.
That's not true. You can't close the socket from the thread that's blocking, but that's trivially obvious and not relevant. You can close the socket from whatever thread needs to interrupt the thread that's blocking. A blocking read can be interrupted just as easily as a non-blocking read.
So how can i cancel the blocked read?
Same as you cancel a non-blocking read: close the i/o object.
Should i raise and handle a RequestCancelle d Event?
Should you raise and handle what RequestCancelle d event?
Pete
On Jun 4, 2:10 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Wed, 04 Jun 2008 06:24:43 -0700, parez <psaw...@gmail. comwrote:
1)
If I use sync api, I would be blocking on the read hence not able to
close the socket.
That's not true. You can't close the socket from the thread that's
blocking, but that's trivially obvious and not relevant. You can close
the socket from whatever thread needs to interrupt the thread that's
blocking. A blocking read can be interrupted just as easily as a
non-blocking read.
So how can i cancel the blocked read?
Same as you cancel a non-blocking read: close the i/o object.
Should i raise and handle a RequestCancelle d Event?
Should you raise and handle what RequestCancelle d event?
Pete
what i am trying to ask is which thread will/should close the i/o
object? since the current thread is blocked on the read, i thougtt i
could create a RequestCancled event which would be raised by the UI
and it could be handled by the communciation Layer or any other
layer..
On Wed, 04 Jun 2008 11:43:49 -0700, parez <ps*****@gmail. comwrote:
what i am trying to ask is which thread will/should close the i/o
object? since the current thread is blocked on the read, i thougtt i
could create a RequestCancled event which would be raised by the UI
and it could be handled by the communciation Layer or any other
layer..
You could do that. But I don't see the point. It would mean that the
communication layer would wind up not just a service that your GUI uses,
but also as an active user/subscriber of the API that your GUI exposes.
Why not just have a method in your communication layer that the GUI can
call to cancel the i/o? Which thread it's called from doesn't really
matter; it just depends on what circumstance causes you to want to cancel
the i/o. If it's a user pushing a "Cancel" button, it'll probably be the
GUI thread that calls the method. If it's a timer or response to some
other condition, it could be some other thread (as appropriate to the
timer or other condition).
Pete
On Jun 4, 2:51 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Wed, 04 Jun 2008 11:43:49 -0700, parez <psaw...@gmail. comwrote:
what i am trying to ask is which thread will/should close the i/o
object? since the current thread is blocked on the read, i thougtt i
could create a RequestCancled event which would be raised by the UI
and it could be handled by the communciation Layer or any other
layer..
You could do that. But I don't see the point. It would mean that the
communication layer would wind up not just a service that your GUI uses,
but also as an active user/subscriber of the API that your GUI exposes.
Why not just have a method in your communication layer that the GUI can
call to cancel the i/o? Which thread it's called from doesn't really
matter; it just depends on what circumstance causes you to want to cancel
the i/o. If it's a user pushing a "Cancel" button, it'll probably be the
GUI thread that calls the method. If it's a timer or response to some
other condition, it could be some other thread (as appropriate to the
timer or other condition).
Pete
Hmm.. This means I will have to create another path down the tiers
for request cancellations and also keep a reference of the objects of
the underylying tier so i can traverse down to the blocked object.
Thanks Pete and rest for the replies.
On Thu, 05 Jun 2008 09:11:07 -0700, parez <ps*****@gmail. comwrote:
Hmm.. This means I will have to create another path down the tiers
for request cancellations and also keep a reference of the objects of
the underylying tier so i can traverse down to the blocked object.
Yes. But I don't see how that wouldn't be the case regardless of the i/o
implementation. You can't cancel something unless you know what that
something is. :)
Pete
On Jun 5, 2:33 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Thu, 05 Jun 2008 09:11:07 -0700, parez <psaw...@gmail. comwrote:
Hmm.. This means I will have to create another path down the tiers
for request cancellations and also keep a reference of the objects of
the underylying tier so i can traverse down to the blocked object.
Yes. But I don't see how that wouldn't be the case regardless of the i/o
implementation. You can't cancel something unless you know what that
something is. :)
Pete
Yea.. When i designed it, I didn't consider the cancellation
possibillity or a need to follow an existing object trail.Its small
change though.
Thanks for your input. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bob Alston |
last post by:
Anyone out there successfully deployed Data Access Pages, on a server
they do not control, using RDS in a 3-tier environment? If so I would
like to hear about your success.
From my reading, RDS is not widely available on commercial servers due
to security issues advised by Microsoft (see prior posts). I have done
it successfully in a two tier environment - which (according to
Microsoft) is where the page is on a server, but the access...
|
by: Joey Powell |
last post by:
Re: Original post = Windows forms - how do I get them to render/update
properly? from August 22.
Okay I am making some progress with being able to use delegates to run
my shelled processes on worker threads. Yes I have gotten it to work,
kind-of - that is I have gotten the shelled processes off of the UI
thread (I think?). But the UI still is not updating properly! Still I
have white boxes for forms, label text that does not update, and...
|
by: johkar |
last post by:
I have two problems I cannot work out in the following tab code with
Netscape 6. Problems are marked with all cap comments. One is that
the background image is not shown in NS 6 (two places in CSS). The
second problem is that the top right rounded corner is not showing up
in the Tier 2 tabs. Could you have a look and tell me if it is
possible to correct? This code seems to work fine in IE 5+ and
Firefox. Note that since I can't post...
|
by: Dan Munk |
last post by:
Hello,
I am working on a very large multi-tier Web application. The
application consists of approximately 100 middle-tier/back-end projects
and 200-300 presentation projects. Obviously this is too large to
manage in a single solution. The development staff have each developed
ways to work within such a behemoth structure, but we have not been
able to come up with a standard for project-to-solution organization
and how to manage...
|
by: David Veeneman |
last post by:
Does anyone knmow why an asynchronous worker method would crash if the
e.Cancel method is set to true, but not otherwise?
I'm working on a demo app with an asynchronous call, using the .NET 2.0
BackgroundWorker component. The app works fine if I let the worker method
proceed to completion. But if I cancel the worker method, it crashes.
Specifically, if I set the DoWorkEventArgs.Cancel property to true, the
worker thread crashes at the...
| |
by: Jon Davis |
last post by:
I have a couple questions. First of all, would anyone consider a
multi-layered programming approach (building business objects that are
seperate from data access logic and seperate from user interface logic but
that interface the UI and the data) an n-tier implementation by definition?
Or does n-tier necessitate a network-distributed architecture (beyond IIS
and SQL Server, i.e. COM+/MTS/MSMQ/WCF) in addition to the layered
programming? If...
|
by: Jesse Aufiero |
last post by:
I'm wondering what the rule is on how to assure that the background worker
'DoWork' routine is truly running entirely in the background. My DoWork
routine calls another procedure which resides in a shared class. This other
procedure has local variables but also refrences class level variables. I'm
wondering if this might cause the DoWork routine to have to reach out to the
primary thread, thus greatly slowing down the routine.
How can...
|
by: Smokey Grindel |
last post by:
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...
|
by: Infog |
last post by:
I am trying to code a simple background workers class without needing to use the backgroundworker object on a form. This would allow me to use a background worker in any class without writing much additional code. Is it possible to pass in the name of a sub at runtime instead of hard-coding it? To do this I would replace onDoWork and onProgressChanged below and use (Byval onWorkSub as SomeKindOfObject?, Byval onProgressChangedSub as...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |