Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2007

Tip: Looking for answers? Try searching our database.

create new StackTrace-object for a thread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Markus Eßmayr - 02 Apr 2007 12:50 GMT
Hi,

in my application I need to get the current executing location of a thread.
Until now I did this by

Thread executingThread;
...
executingThread.Suspend();
StackTrace executionLocation = new StackTrace(executingThread, false);
executingThread.Resume();
...

This works very good.
Since .NET Framework 2.0 the Suspend and Resume functions are marked
obsolete.
But the documentation of the StackTrace constructor still says "If a
StackTrace is created with a target thread that is not the current thread,
the target thread must first be suspended."

Can anyone please tell me how to suspend a thread without using
Thread.Suspend?

Thanks in advance!

Max
Lloyd Dupont - 03 Apr 2007 04:32 GMT
It's obsolete because....
the little caution box in the documenttation, down the page.
Let me copy it there for you:
---
Do not use the Suspend and Resume methods to synchronize the activities of
threads. You have no way of knowing what code a thread is executing when you
suspend it. If you suspend a thread while it holds locks during a security
permission evaluation, other threads in the AppDomain might be blocked. If
you suspend a thread while it is executing a class constructor, other
threads in the AppDomain that attempt to use that class are blocked.
Deadlocks can occur very easily.
---

Meanwhile you could ((almost) safely) use suspend for suspending need...

> Hi,
>
[quoted text clipped - 22 lines]
>
> Max

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.