c# - Tiny stub of bogus code purely for the purpose of setting a breakpoint (that doesn't create a compiler warning) -
this trivial question find myself thinking time - when debugging, want break right after line of code executes, , rather putting breakpoint on next line of code (which may ways down due large comment blocks, or putting on last line of code , hitting f10 go on after breaks, have urge put short stub line on set breakpoint.
in vba i'd use doevents this, shortest thing in c# i've found doesn't create annoying compiler warning (the variable 'x' declared never used) is:
int x = 1; x++;
is can get, or there other obvious approach i'm not aware of?
note: aware of suppressing warnings via:
#pragma warning disable 0168 // rid of 'variable never used warning'
...but find sporadically doesn't work.
for debugging purposes, use system.diagnostics.debugger.break()
. in practice, it's inserting break point on statement easier determine function after fact, , maintained through source control between users , systems. doesn't clutter breakpoints window. also, helpfully enough, not trigger when running in release mode, allowing place these in areas of critical importance, , leave them in without harming customer releases.
as alternate suggestion, following inbetween's comment:
if, instead, looking "harmless" statement can set breakpoint on when desire, thread.sleep(0) should similar enough anecdotal vba solution suffice debugging purposes.
thread.sleep(0). tells system want forfeit rest of thread’s timeslice , let another, waiting, thread run.
-- http://blogs.msmvps.com/peterritchie/2007/04/26/thread-sleep-is-a-sign-of-a-poorly-designed-program/
this less ideal solution in mind first suggestion, may more you're looking for.
Comments
Post a Comment