473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Abort a thread

Hi
I am trying to implement the Abort functionality in progress bar
control. Scenario is like this.

I have a web application which performs a very long computation
process. This computation process starts when I click calculate button
on that webworm.

On Calculate click two functionalities are implemented
1)When I click on calculate it open a progress bar pop up .This
progress bar uses JavaScript to update the status and filling up of
span to show the percentage complete
2)Also a request is being posted on to perform a long computation.

During this long wait ,if user wants to abort the computation he has to
clcik on Abort button provided on progress bar pop up. In this Abort
button functionality I call the function on main page to abort this
request. Limitations I face here are

1)This abort request is processed after computation request is
complete. So it 's of no use.
2)I used thread here to avoid this problem. But limitations I face here
are
a)My calculation process includes three steps Maping data from screen,
Perform calculations on that mapped data, Bind the calculations with
screen.
b)All the three functions described above should occur synchronously.
c)Thread method to be executed when thread starts is "Perform
calculations"
d)"BindData' function is dependent on Perform Calculations

I cannot put MapData() and BinData() in thread , as thread throws null
reference exception. It never gets the context.

Please tell me where I am going wrong or suggest a new approach to
resolve the problem.

pseudo code for help

bool ThreadCompleted = false;
protected void btnCompute_Click(sender,event Args)
{
MapDataFromScreen();
workerStart = new ThreadStart(PerformAnalysis);
workerThread = new Thread(workerStart);
workerThread.Start();
BindData();
}

private void PerformAnalysis
{
//Perform long calculations
ThreadCompleted = true;
}

private void BindData()
{
if(ThreadCompleted)
{
//Bind Grid and labels with new calculations
}
}

//This event does not get called unless the Bind Data function is
complete.How to avoid this??
protected void Abort()
{
workerThread.Abort();
}

Can some body help me on this..??

Dec 26 '05 #1
0 983

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Keith Langer | last post by:
I have an application which consists of a main work thread and multiple threads which each maintain a TCP socket. When a configuration change occurs, all activity on the socket threads must be...
14
by: Daisy | last post by:
From this page: http://www.c-sharpcorner.com/2/mt_beginner1.asp Thread class's Abort method is called to kill a thread permanently. Make sure you call IsAlive before Abort. if (...
7
by: Morris | last post by:
I want to abort a running thread, so I call MyThread.abort() function. My problem is this thread runs "almost" like a while(true) loop and I don't want the Abort() function interrupts the thread at...
20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
5
by: [Yosi] | last post by:
Why I can't abot a susspended thread. Who can terminat a thread imediatly without consider to its stat or execution?
18
by: Urs Vogel | last post by:
Hi I wrote an application server (a remoting sinlgeton), where processes must be stopped in very rare cases, done thru a Thread.Abort(). Occasionally, and only after a Thread.Abort(), this...
4
by: fred | last post by:
I use a Synclock in a secondary thread and also stop the thread using the abort method. If the abort occurs while the thread is in the Synclock will the SyncLock always be released before the...
6
by: Joe HM | last post by:
Hello - I have a function that calls Thread.Abort() to stop a thread in a _Closed() Method of a GUI. The thread contains a blocking call on a TCP socket and that is the easiest way to stop...
5
by: andrew | last post by:
Hi, I have the following issue with the Thread.Abort(): The main thread creates a worker thread which waits on a process termination. void ThreadProc() { Process proc =...
6
by: mehdi | last post by:
Hi folks, You know, the Thread class has got a method named Abort which according to the msdn: "Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.