vb.net - .Net Asynchronous Delegate Abortion -
background: application used execute tests using selenium rc servers, , i'm running problem when call selenium command doesn't return response rc server - ends blocking thread executing test.
sample code:
private delegate function docommand_delegate(byval command string, byval args() string) string ... asynccommand = new docommand_delegate(addressof server.docommand) asyncresult = asynccommand.begininvoke(command, args, nothing, nothing) try ... (i have use asyncwaithandle wait periods of 10 seconds 2 minutes. @ end of each period runs checks common problems block selenium returning response (modal dialogs) - don't think part relevant question, it's necessary.) result = asynccommand.endinvoke(asyncresult) ... at time endinvoke called, worker delegate has either finished or needs aborted. of time has response works fine, on rare occasion selenium rc's docommand doesn't return, thread sits there locked.
finally, question: there resource-friendly way abort executing delegate, or need convert use manually controlled thread can aborted , disposed?
note: not question regarding selenium, proper multithreading.
note 2: i've considered doing following in finally before calling endinvoke:
if not asyncresult.iscompleted asyncresult.asyncwaithandle.close() ... don't know if work correctly, or damage cause.
there no way following @ same time:
- abort/kill thread non-cooperatively
- without destroying state associated (appdomain/process)
implies: either terminate cooperatively (not possible here) or kill process (appdomain not enough because native state involved) or don't kill thread.
you not kill thread , leave there hanging. rest of program (the remaining tests) can continue execute.
i'd not happy see in production test suite ok (assuming hang cannot fixed).
why can't thread aborted? has been covered number of times on stack overflow already.
Comments
Post a Comment