473,405 Members | 2,444 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,405 software developers and data experts.

Cancel a thread - please help

JJ
Is there any way to allow the user to cancel a thread which carries out a
single long task. My form app's thread submits data to a web form via a
webclient instance. There is some considerable delay whilst the data is
retrieved. I am trying to avoid using thread.abort - is this possilbe?

My thread does a task similar to:

Dim wc As New Net.WebClient 'the webclient
Dim bt() As Byte 'the returned bytes
Dim html As String 'the returned HTML text
bt = wc.UploadValues(FormUrl, fields) 'send fields and retrieve response
<--** long task - would like to allow user to cancel it safely

Really need some help here,

Thanks
Jan 30 '06 #1
3 1240
try this:

Dim myThread as New Thread(AddressOf myThreadBegin)

Private Sub myThreadBegin()

''Do work here

end sub

Private Sub Button1_Click(...)handles Button1.Click

try
myThread.Abort()

end sub

--
-iwdu15
Jan 30 '06 #2
haha sry about that last post, let me finish the code here
Dim myThread as New Thread(AddressOf myThreadBegin)

Private Sub myThreadBegin()

''Do work here

end sub

Private Sub Button1_Click(...)handles Button1.Click

try

myThread.Abort()

catch ta as ThreadAbort

end sub
--
-iwdu15

Jan 30 '06 #3
JJ
Thanks - finally a reply.
I think that its not possible to avoid a Thread.Abort in this scenario. So I
will use your approach here, unless someone can tell me otherwise.


"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:B7**********************************@microsof t.com...
haha sry about that last post, let me finish the code here
Dim myThread as New Thread(AddressOf myThreadBegin)

Private Sub myThreadBegin()

''Do work here

end sub

Private Sub Button1_Click(...)handles Button1.Click

try

myThread.Abort()

catch ta as ThreadAbort

end sub
--
-iwdu15

Jan 31 '06 #4

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

Similar topics

2
by: Steven | last post by:
Hello I need some help with canceling a thread. Here is a simple code that creates and cancels a thread. It does create a thread BUT it doesnt cancel it, am I doing this wrong? Thank you! ...
4
by: Mike - EMAIL IGNORED | last post by:
Using RoseRT with RedHat 8.0, I have a thread that is waiting for a cin, and another thread that wants to cancel the cin without waiting for a response from the keyboard. I tried destroying the...
3
by: Jacob | last post by:
I'm writing a class that communicates with a server using the TcpClient class. Most of the methods I've written are intended to be used synchronously and will block until they are completed. But...
1
by: VM | last post by:
How can I cancel all running processes in my application when I click on the Cancel button? When the Run button's clicked, it creates an instance of a specified class and runs a method that reads...
1
by: Jeffrey Kingsley | last post by:
I would like to cancel a call to BeginInvoke of a delegate (i.e. kill the thread the call was made on). This would be done when a timeout occures for the waitone call to the WaitHandle object of...
6
by: Ken Varn | last post by:
I have an ASP.NET form that may take a very long time to process a particular request. If the user closes the browser window, the request will continue to process until it completes. This is a...
1
by: holysmokes99 | last post by:
I am trying to implement a cancel button on my application that ingests a bunch of data from a text file into a database. I have not worked too much with threads, so I am having some trouble. I had...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
16
by: parez | last post by:
I start a BackGroundWorker 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->Communication Layer and it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
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,...
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.