Hi Everybody
I was wondering if you experts could cast your eyes over the following code
and tell me if I'm doing anything obviously wrong. The code works but causes
some unexpected things in an application I'm writing e.g. a form I'm setting
to be hidden using .Hide is not hidden:
Private m_threadProgress As New Thread(AddressOf ProgressForm)
' the next few lines occur in a sub
If Me.m_threadProgress.IsAlive = False Then
Me.m_threadProgress = New Thread(AddressOf ProgressForm)
End If
Me.m_threadProgress.Start()
' do some other stuff
Me.m_threadProgress.Abort()
' display another form
Can you give me any advice as to whether I'm doing this correctly?
Thanks in advance
G 8 976
>Can you give me any advice as to whether I'm doing this correctly?
Calling Thread.Abort is generally a bad idea. Other than that it's
hard to say anything without seeing more of your code. Are you
creating or interacting with any UI components from your background
thread?
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Hi Mattis
The thread displays a form with some flashing text. I'm using it to show
that long calculations are proceeding.
You say that Thread.Abort is a bad idea. How should I stop the thread and
dispose of it when it is no longer in use?
Thanks for your help.
"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Can you give me any advice as to whether I'm doing this correctly?
Calling Thread.Abort is generally a bad idea. Other than that it's
hard to say anything without seeing more of your code. Are you
creating or interacting with any UI components from your background
thread?
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Do you by chance have a form that is opening as a showmodal form in a
different thread?
If so, could you lemmi know how u did that. Ive been trying to do something
simillar.
Miro
"G .Net" <no********@email.comwrote in message
news:VO********************@pipex.net...
Hi Mattis
The thread displays a form with some flashing text. I'm using it to show
that long calculations are proceeding.
You say that Thread.Abort is a bad idea. How should I stop the thread and
dispose of it when it is no longer in use?
Thanks for your help.
"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Can you give me any advice as to whether I'm doing this correctly?
Calling Thread.Abort is generally a bad idea. Other than that it's hard to say anything without seeing more of your code. Are you creating or interacting with any UI components from your background thread?
Mattias
-- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
In the form, create a boolean property to tell the form you are ready for it
to close. Then, where you use the thread.Abort(), simply set this property
to true. Inside the form's code, periodically check this flag and exit.
Mike Ober.
"G .Net" <no********@email.comwrote in message
news:VO********************@pipex.net...
Hi Mattis
The thread displays a form with some flashing text. I'm using it to show
that long calculations are proceeding.
You say that Thread.Abort is a bad idea. How should I stop the thread and
dispose of it when it is no longer in use?
Thanks for your help.
"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Can you give me any advice as to whether I'm doing this correctly?
Calling Thread.Abort is generally a bad idea. Other than that it's hard to say anything without seeing more of your code. Are you creating or interacting with any UI components from your background thread?
Mattias
-- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Hi Michael
How can I set the property of the form from the thread?
G
"Michael D. Ober" <obermd.@.alum.mit.edu.nospamwrote in message
news:OV*************@TK2MSFTNGP05.phx.gbl...
In the form, create a boolean property to tell the form you are ready for
it to close. Then, where you use the thread.Abort(), simply set this
property to true. Inside the form's code, periodically check this flag
and exit.
Mike Ober.
"G .Net" <no********@email.comwrote in message
news:VO********************@pipex.net...
>Hi Mattis
The thread displays a form with some flashing text. I'm using it to show that long calculations are proceeding.
You say that Thread.Abort is a bad idea. How should I stop the thread and dispose of it when it is no longer in use?
Thanks for your help.
"Mattias Sjögren" <ma********************@mvps.orgwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Can you give me any advice as to whether I'm doing this correctly?
Calling Thread.Abort is generally a bad idea. Other than that it's hard to say anything without seeing more of your code. Are you creating or interacting with any UI components from your background thread?
Mattias
-- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Hi Miro
In the code I used above, simply have
Private Sub ProgressForm()
Dim form As MyForm = New MyForm()
form.ShowDialog()
End Sub
However, the problem is how do we close the form succesfully? From what I
gather, using Abort is not a good idea; although it does appear that the
form is closed in calling it.
G
"Miro" <mi******@golden.netwrote in message
news:u5**************@TK2MSFTNGP03.phx.gbl...
Do you by chance have a form that is opening as a showmodal form in a
different thread?
If so, could you lemmi know how u did that. Ive been trying to do
something simillar.
Miro
"G .Net" <no********@email.comwrote in message
news:VO********************@pipex.net...
>Hi Mattis
The thread displays a form with some flashing text. I'm using it to show that long calculations are proceeding.
You say that Thread.Abort is a bad idea. How should I stop the thread and dispose of it when it is no longer in use?
Thanks for your help.
"Mattias Sjögren" <ma********************@mvps.orgwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Can you give me any advice as to whether I'm doing this correctly?
Calling Thread.Abort is generally a bad idea. Other than that it's hard to say anything without seeing more of your code. Are you creating or interacting with any UI components from your background thread?
Mattias
-- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Generally, I would have the thread do the work and have the flashing dialog
in my main UI thread. You can have the thread trigger an event that you
catch in the UI thread when the worker thread is done calculating then close
the dialog by calling a method from the finished event that the worker thread
fired.
--
Dennis in Houston
"G .Net" wrote:
Hi Miro
In the code I used above, simply have
Private Sub ProgressForm()
Dim form As MyForm = New MyForm()
form.ShowDialog()
End Sub
However, the problem is how do we close the form succesfully? From what I
gather, using Abort is not a good idea; although it does appear that the
form is closed in calling it.
G
"Miro" <mi******@golden.netwrote in message
news:u5**************@TK2MSFTNGP03.phx.gbl...
Do you by chance have a form that is opening as a showmodal form in a
different thread?
If so, could you lemmi know how u did that. Ive been trying to do
something simillar.
Miro
"G .Net" <no********@email.comwrote in message
news:VO********************@pipex.net...
Hi Mattis
The thread displays a form with some flashing text. I'm using it to show
that long calculations are proceeding.
You say that Thread.Abort is a bad idea. How should I stop the thread and
dispose of it when it is no longer in use?
Thanks for your help.
"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl... Can you give me any advice as to whether I'm doing this correctly?
Calling Thread.Abort is generally a bad idea. Other than that it's hard to say anything without seeing more of your code. Are you creating or interacting with any UI components from your background thread?
Mattias
-- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Yeah Im trying something similar but once all my calculations are done, I
put a command button "close" that shows up that the user selects to
continue.
-User wanted to know it was complete instead of it dissapearing
automatically.
I will try to close it automatically and see what I find too. Ill be
hitting my code this weekend agian.
Miro
"G .Net" <no********@email.comwrote in message
news:Ef******************************@pipex.net...
Hi Miro
In the code I used above, simply have
Private Sub ProgressForm()
Dim form As MyForm = New MyForm()
form.ShowDialog()
End Sub
However, the problem is how do we close the form succesfully? From what I
gather, using Abort is not a good idea; although it does appear that the
form is closed in calling it.
G
"Miro" <mi******@golden.netwrote in message
news:u5**************@TK2MSFTNGP03.phx.gbl...
>Do you by chance have a form that is opening as a showmodal form in a different thread?
If so, could you lemmi know how u did that. Ive been trying to do something simillar.
Miro
"G .Net" <no********@email.comwrote in message news:VO********************@pipex.net...
>>Hi Mattis
The thread displays a form with some flashing text. I'm using it to show that long calculations are proceeding.
You say that Thread.Abort is a bad idea. How should I stop the thread and dispose of it when it is no longer in use?
Thanks for your help.
"Mattias Sjögren" <ma********************@mvps.orgwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl.. . Can you give me any advice as to whether I'm doing this correctly?
Calling Thread.Abort is generally a bad idea. Other than that it's hard to say anything without seeing more of your code. Are you creating or interacting with any UI components from your background thread?
Mattias
-- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark Stokes |
last post by:
Hi there,
I wanted a bit of advice on a program (a prototype) that I am trying
to write that uses threads. I will outline what I am attempting to
do, and if anyone has any advice on the way I...
|
by: vpr |
last post by:
Hi Guys
I have a question re. socketserver and wx.
I've written a p2p program using socketserver that's nice and quick.
I'd like to give the user a tray applet (part of the p2p service) that...
|
by: Calimero |
last post by:
I have to write a middleware that could be see as a very
specialized Web server (based on threads and sockets)
I hesitate between C++ (speed) and C# (more elegant)
What is the performance penalty...
|
by: Cider123 |
last post by:
I ran into a situation where my Window Service had to process 100,000+
files, when I first noticed I needed to tweak various routines.
Everything runs fine, but here's what I ran into:
In the...
|
by: Ekempd |
last post by:
Hi I need some advice about this situation an how I'm current handling it
I hava a ASP.NET solution that in some point start multiples lenghty
verification agains diferent databases, my big...
|
by: frizzle |
last post by:
Hi there,
I'm going to build a simple forum in mySQL.
I've thought about it for a while now, but still can't figure it
out completely:
If i have say 5 main categories,
One has 5...
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej...
|
by: Ben Fidge |
last post by:
My application uses a singleton static class for writing entries to a log
file. The location and name of the log-file is read from web.config each time
an entry is written, but has the current date...
|
by: Ramon F Herrera |
last post by:
My goal is to write a studio-type application which will initially run
on Windows, but I would like it to run on other platforms with minimum
efforts.
I have made the decision to go with C++.
...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
| |