|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cancel a thread - please helpIs 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 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 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 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. Show quoteHide quote "iwdu15" <jmmgoalsteratyahoodotcom> wrote in message news:B70A85C8-30A1-4515-84B2-D5D32B7E9F37@microsoft.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 >
Windows forms application
It's the little things change value of textbox in datagrid How to get cmdArgs in Windows Application (vs2005) ? Permutation listing Tell to ASP.Net don't watch some web folders multiple tcp connections Problem while referencing the multiple projects in same solution. NumericUpDown Control Search Directories |
|||||||||||||||||||||||