473,321 Members | 1,877 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,321 software developers and data experts.

Tread Abort Without Message

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
Nov 21 '05 #1
9 1217
"Li Pang" <Li****@discussions.microsoft.com> schrieb:
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.


<URL:http://www.google.de/groups?threadm=OWoxa8lxEHA.2192%40TK2MSFTNGP14.phx .gbl>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2
"Li Pang" <Li****@discussions.microsoft.com> schrieb:
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.


<URL:http://www.google.de/groups?threadm=OWoxa8lxEHA.2192%40TK2MSFTNGP14.phx .gbl>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #3
Hi Herfried K. Wagner ,

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

"Herfried K. Wagner [MVP]" wrote:
"Li Pang" <Li****@discussions.microsoft.com> schrieb:
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.


<URL:http://www.google.de/groups?threadm=OWoxa8lxEHA.2192%40TK2MSFTNGP14.phx .gbl>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #4
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" <Li****@discussions.microsoft.com>

...
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

Nov 21 '05 #5
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".

"Cor Ligthert" wrote:
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" <Li****@discussions.microsoft.com>

...
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


Nov 21 '05 #6
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"
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".

"Cor Ligthert" wrote:
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" <Li****@discussions.microsoft.com>

...
> 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


Nov 21 '05 #7
Hi Cor,
I mean "btnStopSearch" button. The message came anyway.

"Cor Ligthert" wrote:
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"
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".

"Cor Ligthert" wrote:
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" <Li****@discussions.microsoft.com>

...
> 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


Nov 21 '05 #8
Li,

There is no btnStopSearch in my sample

Cor

"Li Pang" <Li****@discussions.microsoft.com>
Hi Cor,
I mean "btnStopSearch" button. The message came anyway.

"Cor Ligthert" wrote:
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"
> 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".
>
> "Cor Ligthert" wrote:
>
>> 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" <Li****@discussions.microsoft.com>
>>
>> ...
>> > 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
>>
>>
>>


Nov 21 '05 #9
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.

"Cor Ligthert" wrote:
Li,

There is no btnStopSearch in my sample

Cor

"Li Pang" <Li****@discussions.microsoft.com>
Hi Cor,
I mean "btnStopSearch" button. The message came anyway.

"Cor Ligthert" wrote:
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"

> 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".
>
> "Cor Ligthert" wrote:
>
>> 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" <Li****@discussions.microsoft.com>
>>
>> ...
>> > 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
>>
>>
>>


Nov 21 '05 #10

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 (...
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...
0
by: Li Pang | last post by:
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. ...
5
by: Bob Altman | last post by:
Hi all, I have a WinForms app that has no main window (just a module with a Sub Main). My Main routine calls a subroutine that wants to politely abort the application rather than return to its...
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...
4
by: raghudr | last post by:
Hi all, I am implemeting a splash screen in C# I got a useful link from here :- http://www.codersource.net/csharp_splash_screen.aspx //Logic when to display a splash screen is:- Splash...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.