c# - Understanding when/how events are sent -


i have code this:

// create event handler delegate symbolreader.readnotify += new eventhandler(symbolreader_readnotify); 

when barcode scanned on handheld device symbolreader_readnotify called.

this simplified version of method:

/// <summary> /// event fires when symbol scanner has performed scan. /// </summary> private void symbolreader_readnotify(object sender, eventargs e) {     readerdata readerdata = symbolreader.getnextreaderdata();      // if successful scan (as opposed failed one)     if (readerdata.result == results.success)     {         // setup next scan (because may need scanner          // in onbarcodescan event below         start();          // handle of window user on when scan sent.         intptr handle = coredll.gettopwindow();          // if have barcode scanner method window call delegate now.         if (_scandelegates.containskey(handle))         {             action<barcodescannereventargs> scandelegate;             // method call handle              // (previously added _scandelegates dictionary)             bool delegateretrieved = _scandelegates.trygetvalue(handle, out scandelegate);             if (delegateretrieved && (scandelegate != null))                 scandelegate(e);          }     } } 

that works fine of time. when call scandelegate opens new window also needs accept scans event (symbolreader.readnotify) not fire (when scan done on window). once window closes (and scandelegate(e) returns) event fire (but route wrong window.

is there someway tell app send event? work windows messages (i.e. there way flush messages) or symbol library failing send event until late?)

the 1 thing have tried calling application.doevents in loop in window opened. not seem work.

note: compact framework app, don't think compact framework issue, not tagging compact framework.

any advice event fire when scan happens (like when not nested scan) great!

does scandelegate(e) open new window dialog? if it'll block event raising again untill it's closed because it's called (opened) within same eventhandler.

you can work around either delaying opening untill after event handled, not opening dialog or opening on new thread (or use begininvoke on delegate)


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -