473,387 Members | 1,603 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,387 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 1218
"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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
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
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...

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.