.net - C# Application does not crash in VS BUT CRASH on system running -
i'm developing simple test tool verify how many hash(sha1) customer server can elaborate in 1 second.
the attached sample use muti-threading start , stop timer counts executed hash. hashes sequential.
the application works in visual studio, if run outside vs environment crashes.
the problem on increment() function in "using" section. if comment it, works well!
static void increment() { try { using (sha1 sha = new sha1cryptoserviceprovider()) { byte[] result; byte[] data = new byte[20]; new random().nextbytes(data); result = sha.computehash(data); } interlocked.increment(ref safeinstancecount); } catch (exception ex) { console.writeline(ex.message); } }
the code used start , stop time following:
bool stop; static void main() { try { timerqueuetimer qt; qt = new timerqueuetimer(); timerqueuetimer.waitortimerdelegate callbackdelete = new timerqueuetimer.waitortimerdelegate(queuetimercallback); uint duetime = uint.parse(textbox1.text); // string "60000" = 1 min uint period = 0; qt.create(duetime, period, callbackdelete); while (!stop) { // thread thread = new thread(new threadstart(increment)); // thread.isbackground = true; // thread.start(); increment(); } stop = false; } catch (exception ex) { console.writeline(ex.message); } } private void queuetimercallback(intptr pwhat, bool success) { try { stop = true; } catch (exception ex) { console.writeline(ex.message); } }
how can understand error?
=
the application crashes without exception. try catch it, without success, happened after 60 sec. (maybe queuetimercallback called?)
the application not generate error trace , not crash running under visual studio! when crashes not generate stack trace, pop-up crash window giving in detail "stackhash_xxxxx" error
nothing do! i've try use console.read (it's windows app not console) cannot see anything. here error shown! https://picasaweb.google.com/lh/photo/ihsbhrsy-dntyvo4cpoea9mtjnzetymypjy0liipfm0?feat=directlink
your program throwing exception, , it's getting written console, don't have stopping console closing after message written.
add console.readkey();
after try/catch block.
Comments
Post a Comment