By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,996 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,996 IT Pros & Developers. It's quick & easy.

Threads & Memory

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.