473,486 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Question related to threading concept.

Hi all,

I don't have much of knowledge about threading.

I have on .net application where in main i am starting one secondary
thread.

like
public class yyy

{

public void abc()
{
for ( int i = 0; i<=3;i++)
{
System.Console.Write(i + " ");
Thread.Sleep(1);
}
}
}

in form i have code as below on one button

yyy a = new yyy();
Thread t = new Thread(new ThreadStart(a.abc));
t.Start();
Console.WriteLine("complete");
this.Close();
return;
So my question is when i am running one thread which is doing some
heavy processing and mymain application is closing on button click will
it close after secondary thread completes processing or it will close
immediately by keeping second thread running in system.

One more question is what is application.exitthread doing?

Please clear my question related to threading.

Thanks in advance.

Mar 8 '06 #1
2 1407
archana wrote:
Hi all,

I don't have much of knowledge about threading.

I have on .net application where in main i am starting one secondary
thread.

like
public class yyy

{

public void abc()
{
for ( int i = 0; i<=3;i++)
{
System.Console.Write(i + " ");
Thread.Sleep(1);
}
}
}

in form i have code as below on one button

yyy a = new yyy();
Thread t = new Thread(new ThreadStart(a.abc));
t.Start();
Console.WriteLine("complete");
this.Close();
return;
So my question is when i am running one thread which is doing some
heavy processing and mymain application is closing on button click will
it close after secondary thread completes processing or it will close
immediately by keeping second thread running in system.

[It will close immediately, one way to handle this is you have to wait
on some event to wait for the second thread to complete the work. In the
working thread, you set this event when the work completes].
One more question is what is application.exitthread doing? [I think you can look it up in MSDN].

Please clear my question related to threading.

Thanks in advance.

Mar 8 '06 #2
archana,

The process terminates only after all threads running inside finish. When
you terminate the main UI thread the framework will terminate all worker
threads that have IsBackground property set to *true*. All others
IsBackground = false will keep running, thus keep the process alive.

So if you want your UI thread to be survived by the worker thread you set
the worker thread's IsBackground = false and vice versa.
--
HTH
Stoitcho Goutsev (100)
"archana" <tr**************@yahoo.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
Hi all,

I don't have much of knowledge about threading.

I have on .net application where in main i am starting one secondary
thread.

like
public class yyy

{

public void abc()
{
for ( int i = 0; i<=3;i++)
{
System.Console.Write(i + " ");
Thread.Sleep(1);
}
}
}

in form i have code as below on one button

yyy a = new yyy();
Thread t = new Thread(new ThreadStart(a.abc));
t.Start();
Console.WriteLine("complete");
this.Close();
return;
So my question is when i am running one thread which is doing some
heavy processing and mymain application is closing on button click will
it close after secondary thread completes processing or it will close
immediately by keeping second thread running in system.

One more question is what is application.exitthread doing?

Please clear my question related to threading.

Thanks in advance.

Mar 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
1908
by: Uwe Mayer | last post by:
Hi, I have the following inter-class relationships: __main__: (in file LMCMain.py) imports module FileIO defines class LMCMain instanciats main = LMCMain(...) FileIO.py:
77
5207
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
5
2114
by: Richard P | last post by:
I need some help on timers. My app is asp.net 1.1 website running in a shared hosting environment with a third-party service provider. I currently request and cache 20 - 40 remote RSS feeds. When a...
11
4225
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
6
2103
by: rodchar | last post by:
Hey all, I'm trying to understand Master/Detail concepts in VB.NET. If I do a data adapter fill for both customer and orders from Northwind where should that dataset live? What client is...
5
1066
by: microsoft | last post by:
Just researching threading and I'm sure we need to do more review of available resources BUT I'm wondering if what we're looking for is actually possible. If it is we can keep reading. I know...
0
1164
by: archana | last post by:
Hi all, I have some confusion related to threading and autoresetevent. I have 5 threads running for each i have autoresetevent which i am setting through thread procedure. On each of event...
19
1783
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
126
6599
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
0
6964
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
7175
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...
1
6842
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...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4864
isladogs
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...
0
4559
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...
0
1378
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 ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.