473,410 Members | 1,914 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,410 software developers and data experts.

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.EventArgs e)
{
copyFiles = new Thread( new ThreadStart(CopyFilesToProcessFolder) );
copyFiles.Start();
}
Mar 28 '06 #1
3 1512
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*@discussions.microsoft.com> wrote in message
news:83**********************************@microsof t.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.EventArgs e)
{
copyFiles = new Thread( new ThreadStart(CopyFilesToProcessFolder) );
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*@discussions.microsoft.com> wrote in message
news:83**********************************@microsof t.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.EventArgs e)
{
copyFiles = new Thread( new ThreadStart(CopyFilesToProcessFolder) );
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*@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.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*@discussions.microsoft.com> wrote in message
news:83**********************************@microsof t.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.EventArgs e)
> {
> copyFiles = new Thread( new ThreadStart(CopyFilesToProcessFolder) );
> copyFiles.Start();
> }


Mar 28 '06 #4

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

Similar topics

8
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...
3
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...
35
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? ...
167
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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
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,...
0
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
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...

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.