Tread Abort Without Message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have two buttons, one is to start a process, another is to cancel the
process. Wehn I canceled a process, there is an alert message popped up. I'd
like to know how to avoid this popup.

thanks in advance

Private Shared tdSearch As Thread

Private Sub btnSearchNow_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSearchNow.Click
tdSearch = New Thread(AddressOf MyProcess)
tdSearch.IsBackground = True
tdSearch.Start()
End Sub

Private Sub btnStopSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStopSearch.Click
tdSearch.Abort()
End Sub
 
Hi Herfried K. Wagner ,

I couldn't figure out my problem from below web site, please provide me more
details. Thanks.
 
Li,

I tried your code and did not get any message at all.
However why is that shared of the thread?
That I have deleted

\\\
Private tdSearch As Threading.Thread
Private Sub btnSearchNow_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
tdSearch = New Threading.Thread(AddressOf myprocess)
tdSearch.IsBackground = True
tdSearch.Start()
End Sub
Private Sub btnStopSearch_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles Button2.Click
tdSearch.Abort()
Me.Close()
End Sub
Private Sub myprocess()
Threading.Thread.Sleep(40000)
End Sub
///

I hope this helps?

Cor

"Li Pang" <[email protected]>

...
 
Hi Cor Ligthert,

Your codes made the same result, except it closed the form when I clicked on
"Stop". The message was "Thread was being aborted".
 
Li,

Does my code when you tried it give the message "Thread was being aborted?
What do you mean by clicked on stop, there is no "Stop" in my code

Cor

"Li Pang"
 
Cor,

Your code is correct. My issue is due to using catch ex as exception to
catch the error in myprocess. When the thread is aborted, the exception
popped up. That was my fault.

Thanks for your effort.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top