Link to home
Start Free TrialLog in
Avatar of sigmatec_pk
sigmatec_pkFlag for Pakistan

asked on

Thread exception Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Im facing a problem- Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
 Im working on Windows Application .net VS 2008.( im not using Response.Redirect). I got error when the code that is in thread is completed and call myThread.Abort() method. Any idea t solve the problem?
Avatar of daryal
daryal
Flag of Türkiye image

Hello,
are you using a third party tool or dll or unmanaged code (like c) somewhere?
If this is the case, then I think the problem can be related with the unmanaged code.
Also, please note that your thread may be terminated before you call thread.abort.
Avatar of sigmatec_pk

ASKER

@daryal::
thanks for repy. No, im not using any third party dll or unmanaged code. I ve debugged code it executed fine, on thread Completion method when i abort the thread myThread.Abort it goes to catch block.
ASKER CERTIFIED SOLUTION
Avatar of daryal
daryal
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@daryal:

is it not necessary to abort the started thread?
As far as I know, if the thread completes, there is no need to abort it.
In fact, aborting a thread is usable in a few cases and it is done on a purpose, not for every thread.