OK,
I try other option but I still miss somthing , by handle the stat by
parameter of thread,from the father (FORM) when user click on susspend I
change the handle to be suspenrequest, in the thread(call DLL function) after
returning from Dll function call , the thread read the value of the handle if
suspendrequest I do Thread.CurrentThread.Susspend. and change the father
handle stat to be susspend,if not I call Dll function again (this is the
thread, call Dll function in loop).
If this Ok , I have a problem! , when user click on susspend I change the
state to susspenrequest,and wait to thread become susspeneded by read the
thread stat. in this case I sould wait in loop without doing any thing, but
if I do the following :
threadHandler.Susspend();
//Wait for Thread to susspend
do
{
read state if susspend then break;
}
while(true)
the thread(DLL) will not get focuse and it will never continue I don't know
whay ?, why that? the application will stuck in this loop and never continue
execution the thread.
If I try to use Sleep it also Sleep the thread(DLL), How I solve this problem?
Why I can't use Thread.Sleep in the click function inside while as following ?
threadHandler.Susspend();
//Wait for Thread to susspend
do
{
read state if susspend then break;
Thread.Sleep(200);
}
while(true)
Yosi.
"Miha Markic [MVP C#]" wrote:
Hi,
I think that Suspend will suspend only when thread is in safe (managed)
state - this rules out unmanaged execution suspension.
Anyway, it is not a good practice to use Thread.Suspend at all as it is
unpredictable - instead use synchronization mechanisms.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
SLODUG - Slovene Developer Users Group www.codezone-si.info
"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com... Hi,
I create a thread which load DLL and have DLL function call,this Dll
function takes a lot of time.
My Question is , if I request Thread.Susspend(), and the thread is inside
the Dll function (Dll function not finished yet, and thread function wait
for
this function (DLL)call to compleate), what will happen ? is this will
susspend also the Dll function execution ? or will delay the susspend
untill
this function returned ?
Thx