c# - Backgroundworker Stops Working -


i have wpf project uses background workers interfaces external hardware (test & measure equipment, etc), write local files, , insert data database runs. program flow sequential, background workers in use keep gui accessible user, , chosen because haven't had issues using them before. take measurements, stuff, log, repeat. there status log on gui displays messages go.

all of works beautifully hours on end, however, eventually, without fail, appears background worker used write database never calls dowork.

backgroundworker dblogworker = new backgroundworker(); ... dblogworker.dowork +=     new doworkeventhandler(dblogworker_dowork); dblogworker.runworkercompleted +=     new runworkercompletedeventhandler(         dblogworker_runworkercompleted); 

processscandata called when data has been retrieved 1 of pieces of hardware, setting property , firing generic property changed event

(disclaimer: code everywhere investigating see whats going on):

private void data_datasetchanged(object psender, eventargs pargs) {     this.test.processscandata(osavm.osa.data.dataset); }  ... public void processscandata(sortedlist<double,double> pdata) {     ...     raiselogevent(messagetype.systemgeneral, "logging database...");     dblogworker.runworkerasync(new asyncdblogargs(currentchannel, tempdate,         loss1, loss2, loss3,         currenttemperature, currentpressure, currentroomtemp)); }  private void dblogworker_dowork(object psender, doworkeventargs pargs) {     asyncdblogargs args = (asyncdblogargs)pargs.argument;      string filename = string.empty;      try     {         long datakey = db.logscan(currentchannel, args.time,             args.temperature, args.pressure, args.roomtemperature,             args.loss1, args.loss2, args.loss3);         filename = args.time.tostring(folder_datetime_format) + "_[" +    datakey.tostring() + "]";     }     catch (exception ex)     {         filename = args.time.tostring(folder_datetime_format) + "_{" + (fileindex++) + "}";     }      pargs.result = new tuple<asyncdblogargs, string>(args, filename);  } 

symptoms: works fine anywhere between 1 hour , ~16 hours until point see "logging database..." , nothing else ever happens. no more messages, no exceptions (release build on target machine), no database entry...etc. happens consistently.

i've been scratching head on while. leads help, have workarounds in mind i'd know whats going on can avoid in future.

thanks

edited original code...thought recent avoid "how know not firing" questions


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -