c# - Close upcoming Debug Assertion -
i testing debug dlls nunit , annoying every testrun large amount of debug assertions come up.
so have written tool polling new debug assertion. tool iterating windows every x milliseconds , checks if title 1 of collection of possible debug assertion window titles.
in pseudo code looks this:
void main() { var thread = new thread(threadmethod); thread.start(); } private void threadmethod() { while(true) { foreach(var title in possiblewindowtitles) { intptr windowhandle = findwindowhandle(title); if(windowhandle != intptr.zero) { settoforeground(windowhandle); sendkeys.sendwait("%i); } } } }
the codeline sendkeys.sendwait("%i")
sends keycombination of alt + i
window, keycombination "continue" button.
my question is:
there better option? like:
- an event when new window comes up
- a better method of closing window (the
closewindow
methoduser32.dll
hasn't worked me -- no exception, nothing happens) - a better solution
settoforeground()
workaround - the best way suppression of assertion -- possible?
my way works, think solution prone errors. hole there idea
you can configure behavior of dialog box. behavior provided defaulttracelistener, configurable in code or via config file. documentation debug.assert mentions this.
in config file, can turn off ui this:
<configuration> <system.diagnostics> <assert assertuienabled="false" logfilename="c:\myfile.log" /> </system.diagnostics> </configuration>
you can remove default trace listener collection via config file:
<configuration> <system.diagnostics> <trace autoflush="false" indentsize="4"> <listeners> <remove name="default" /> <add name="mylistener" type="system.diagnostics.textwritertracelistener" initializedata="c:\mylistener.log" /> </listeners> </trace> </system.diagnostics> </configuration>
either of these can done via code, debug.listeners
collection.
Comments
Post a Comment