Just some threading questions
1. in a MDI app if you have multiple child forms, does each child
form run in its own thread ? Eg do you get error trying to update one
control on form1 from form 2
2. if you have a timer control running on a childform, and you either
a. minimize or
b. hide the form or
c. the form is no longer the currently selected form ,
does the timer keep running or does it stop ?
3. if you have a timer or a thread running on a child form, and you
close the form or end the application, do you have to stop the thread
or the timer beforehand or does .net cleanup and sort things for you ?
thanks
Peted 5 3252
>1. in a MDI app if you have multiple child forms, does each child
>form run in its own thread ? Eg do you get error trying to update one control on form1 from form 2
No
>2. if you have a timer control running on a childform, and you either a. minimize or
b. hide the form or
c. the form is no longer the currently selected form ,
does the timer keep running or does it stop ?
It keeps running.
>3. if you have a timer or a thread running on a child form, and you close the form or end the application, do you have to stop the thread or the timer beforehand or does .net cleanup and sort things for you ?
You may have to stop the thread (if it's not marked as a background
thread). You probably don't have to stop the timer, but it certainly
doesn't hurt doing so.
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
<Petedwrote:
Just some threading questions
1. in a MDI app if you have multiple child forms, does each child
form run in its own thread ? Eg do you get error trying to update one
control on form1 from form 2
No, unless you've specifically put them in different threads, they'll
be in their own thread.
2. if you have a timer control running on a childform, and you either
a. minimize or
b. hide the form or
c. the form is no longer the currently selected form ,
does the timer keep running or does it stop ?
I believe it keeps running (it would be odd not to) - but that's easy
for you to test.
3. if you have a timer or a thread running on a child form, and you
close the form or end the application, do you have to stop the thread
or the timer beforehand or does .net cleanup and sort things for you ?
The timer will be disposed automatically, and even if somehow it isn't,
it isn't running in a separate foreground thread anyway, so you don't
need to worry.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
"Peted" wrote in message news:j5******** *************** *********@4ax.c om...
1. in a MDI app if you have multiple child forms, does each child
form run in its own thread ? Eg do you get error trying to update one
control on form1 from form 2
They al use the same thread. No problem updating one child form from
another.
2. if you have a timer control running on a childform, and you either
a. minimize or
b. hide the form or
c. the form is no longer the currently selected form ,
does the timer keep running or does it stop ?
It keeps running.
3. if you have a timer or a thread running on a child form, and you
close the form or end the application, do you have to stop the thread
or the timer beforehand or does .net cleanup and sort things for you ?
It depends on how you start the Thread. If you set the IsBackground
property of the thread object to true, then the thread is automatically
stoped when you stop the main program. Otherwise, you have to be careful,
because the thread will continue to run in the background even if you close
all visible forms. No such problem with the Timer Control, which is Disposed
when the form that contains it is Disposed.
<Petedwrote:
<snip>
3. if you have a timer or a thread running on a child form, and you
close the form or end the application, do you have to stop the thread
or the timer beforehand or does .net cleanup and sort things for you ?
Sorry, I only addressed this from the point of view of a WinForms
timer. If you've created a separate thread, and haven't set
IsBackground to true, you'll need to stop the thread.
See http://pobox.com/~skeet/csharp/threads/shutdown.shtml for a pattern
of terminating threads cleanly.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
thanks for all those responses
cheers
On Wed, 21 Mar 2007 15:25:40 +0800, Peted wrote:
>Just some threading questions
1. in a MDI app if you have multiple child forms, does each child form run in its own thread ? Eg do you get error trying to update one control on form1 from form 2
2. if you have a timer control running on a childform, and you either a. minimize or
b. hide the form or
c. the form is no longer the currently selected form ,
does the timer keep running or does it stop ?
3. if you have a timer or a thread running on a child form, and you close the form or end the application, do you have to stop the thread or the timer beforehand or does .net cleanup and sort things for you ? thanks
Peted
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jane Austine |
last post by:
As far as I know python's threading module models after Java's.
However, I can't find something equivalent to Java's interrupt and
isInterrupted methods, along with InterruptedException.
"somethread.interrupt()" will wake somethread up when it's in
sleeping/waiting state.
Is there any way of doing this with python's thread? I suppose thread
interrupt is a very primitive functionality for stopping a blocked
thread.
|
by: Z D |
last post by:
Hello,
I'm having a strange problem that is probably due to my lack of
understanding of how threading & COM Interop works in a WinForms.NET
application.
Here's the situation:
I have a 3rd party COM component that takes about 5 seconds to run one of
its functions (Network IO bound call). Since I dont want my GUI to freeze
|
by: Dan |
last post by:
I've created a pocketpc app which has a startup form containing a listview.
The form creates an object which in turn creates a System.Threading.Timer.
It keeps track of the Timer state using a TimerState object similar to the
example in the System.Threading.Timer documentation. The method which
handles the timer events, among other things, periodically calls a method in
this TimerState object which raises an event to the startup form,...
|
by: Bob |
last post by:
Okay, I've done this for years but now I'm going to question it just because
this idea has been at the back of my head since I started using DotNet...
My WinForms app queries a database every 60 seconds. I set up a singleton
class that's instantiated when the app starts, and that starts a timer. My
question is, would it be better to run this checking process on a separate
thread and have it use its own DB connection? If there isn't a...
|
by: KSC |
last post by:
Hello,
I have used a thread timer as in the documentation on MSDN in my VB.NET
application.
Using System.Threading.Interlocked.Increment I increment the counter to a
certain point, perform an operation, then dispose of the TimerReference. In
this case, the operation is simply enabling a checkbox control.
I have found that the timer will continue to tick at least twice after it is
disposed. Sometimes it will tick several HUNDRED...
| |
by: bob |
last post by:
I am unsure how to approach a C# windows App.
Essentially I want to do this.
I want to write an app that reads from database_A performs some calculations
updates the pretty dials on the screen then writes the 'cooked' data to
database_B (probably not in that order).
Also I will have some buttons on this main window that open some other
winforms so I can capture other bits of info and adjust the main window's
pretty dials and textboxes...
|
by: Giovanni |
last post by:
Hi All,
I need help with the following: Using VB.NET 2005, I am building a
custom class in a separate assembly. The purpose of this class is to poll
the internet to determine connectivity. I have that part functioning
properly using HTTPRequest and HTTPResponse.
The problem lies here: I'd like to execute this monitoring on an
interval (Ex.: every 5 minutes), to get an up-to-date status. This updated
status would then be...
|
by: WhiteWizard |
last post by:
I guess it's my turn to ASK a question ;)
Briefly my problem: I am developing a Windows app that has several User
Controls. On one of these controls, I am copying/processing some rather
large binary files, so have created a second thread to do the processing.
This thread is set to be the LOWEST priority. So far so good with all that.
HOWEVER, I am trying to provide some feedback to the user (the bane of our
existence!) via a progress...
|
by: CCLeasing |
last post by:
For an application I'm creating I want to create a 'fake' progress
bar.
By fake I mean a progress bar that looks like it's doing something but
actually isn't.
I know philosophically this isn't sound. But my little app is a 'fake'
app and is designed to look like another - hence this seeming crazy
situation of needing to fake a progess bar.
PROBLEM.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |