473,804 Members | 3,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Threads & Memory

ano
I create a method that copy files from one folder to another (see the ex.
code).
A new thread will create every time when user click the button.
The button is enable only when the copy process was finished( ThreadState =
Stop )

My question is when ThreadState = Stop, the system will release the Memory
or not?

Is my code generated multiply threads?

Thanks,
Code:

private Thread copyFiles;

private void btnImport_Click (object sender, System.EventArg s e)
{
copyFiles = new Thread( new ThreadStart(Cop yFilesToProcess Folder) );
copyFiles.Start ();
}
Mar 28 '06 #1
3 1533
ano,

What do you mean by releasing a memory.
The thread doesn't own any memory except that it has its own stack. The
memory is own by a process and threads are something like virtual CPUs
executing the code.
--

Stoitcho Goutsev (100)

"ano" <an*@discussion s.microsoft.com > wrote in message
news:83******** *************** ***********@mic rosoft.com...
I create a method that copy files from one folder to another (see the ex.
code).
A new thread will create every time when user click the button.
The button is enable only when the copy process was finished( ThreadState
=
Stop )

My question is when ThreadState = Stop, the system will release the Memory
or not?

Is my code generated multiply threads?

Thanks,
Code:

private Thread copyFiles;

private void btnImport_Click (object sender, System.EventArg s e)
{
copyFiles = new Thread( new ThreadStart(Cop yFilesToProcess Folder) );
copyFiles.Start ();
}

Mar 28 '06 #2
ano
I mean a stack memory. Will it use the same stack or create create a new one
when the button is clicked? Will the threads throw their own stack when their
status is Stop?

Thanks,

"Stoitcho Goutsev (100)" wrote:
ano,

What do you mean by releasing a memory.
The thread doesn't own any memory except that it has its own stack. The
memory is own by a process and threads are something like virtual CPUs
executing the code.
--

Stoitcho Goutsev (100)

"ano" <an*@discussion s.microsoft.com > wrote in message
news:83******** *************** ***********@mic rosoft.com...
I create a method that copy files from one folder to another (see the ex.
code).
A new thread will create every time when user click the button.
The button is enable only when the copy process was finished( ThreadState
=
Stop )

My question is when ThreadState = Stop, the system will release the Memory
or not?

Is my code generated multiply threads?

Thanks,
Code:

private Thread copyFiles;

private void btnImport_Click (object sender, System.EventArg s e)
{
copyFiles = new Thread( new ThreadStart(Cop yFilesToProcess Folder) );
copyFiles.Start ();
}


Mar 28 '06 #3
While there is a code executed by the thread it cannot throw its stack. Once
the thread procedure exits you the thread stack is empty and all local data
is gone anyway. When the thread is finalized all the resources it holds
(including the stack) are released.
--

Stoitcho Goutsev (100)
"ano" <an*@discussion s.microsoft.com > wrote in message
news:9C******** *************** ***********@mic rosoft.com...
I mean a stack memory. Will it use the same stack or create create a new
one
when the button is clicked? Will the threads throw their own stack when
their
status is Stop?

Thanks,

"Stoitcho Goutsev (100)" wrote:
ano,

What do you mean by releasing a memory.
The thread doesn't own any memory except that it has its own stack. The
memory is own by a process and threads are something like virtual CPUs
executing the code.
--

Stoitcho Goutsev (100)

"ano" <an*@discussion s.microsoft.com > wrote in message
news:83******** *************** ***********@mic rosoft.com...
>I create a method that copy files from one folder to another (see the
>ex.
> code).
> A new thread will create every time when user click the button.
> The button is enable only when the copy process was finished(
> ThreadState
> =
> Stop )
>
> My question is when ThreadState = Stop, the system will release the
> Memory
> or not?
>
> Is my code generated multiply threads?
>
> Thanks,
>
>
> Code:
>
> private Thread copyFiles;
>
> private void btnImport_Click (object sender, System.EventArg s e)
> {
> copyFiles = new Thread( new ThreadStart(Cop yFilesToProcess Folder) );
> copyFiles.Start ();
> }


Mar 28 '06 #4

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

Similar topics

8
12956
by: Martin Maat | last post by:
I am puzzled. I have this object that uses a thread. The thread is encapsulated by the object, the object has Start and Stop methods to enable the client to start or stop the thread. I found that the object will not be garbage collected while the thread is running. Fair enough, the documented explanation is that the GC compresses objects on the heap and needs to update references, the references will be invalid for a couple of moments...
3
1651
by: jiing | last post by:
Now I am try to transfer a memory pointer between two threads. but there has a error mesage. _CrtIsValidHeapPointer(pUserData) in dbgheap.c I lookup google and find it's seems to be the local heap in the two threads are different. so their memory that pointer point to are different. I want to ask
35
4050
by: Carl J. Van Arsdall | last post by:
Alright, based a on discussion on this mailing list, I've started to wonder, why use threads vs processes. So, If I have a system that has a large area of shared memory, which would be better? I've been leaning towards threads, I'm going to say why. Processes seem fairly expensive from my research so far. Each fork copies the entire contents of memory into the new process. There's also a more expensive context switch between...
167
8376
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an object should run in its own thread, it should implement this mix-in class. Does this sound like plausible design decision? I'm surprised that C++ doesn't have such functionality, say in its STL. This absence of a thread/object relationship in...
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
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,...
0
10343
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9166
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6861
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();...
0
5529
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...
1
4306
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
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.