c# - No overload when using a BackgroundWorker -


i getting contextswitchdeadlock when try add large amount of graphics map. love use backgroundworker class since have never had opportunity, not sure how in situation.

c#:

private void attributesearchbutton_click(object sender, routedeventargs e)         {             backgroundworker bw = new backgroundworker();             bw.workerreportsprogress = true;             bw.workersupportscancellation = true;             bw.dowork += new doworkeventhandler(runquery);             bw.progresschanged += new progresschangedeventhandler(progresschanged);          }          private void runquery(object sender, doworkeventargs e)         {             _attributequerygraphicslayer.graphics.clear();              querytask querytask = new querytask("http://xx.x.x.xxx:6080/arcgis/rest/services/calvert_city_test/mapserver/2");             querytask.executecompleted += generalquerytask_executecompleted;             querytask.failed += generalquerytask_failed;              var dirty = datetime.utcnow;             query query = new query();             query.outfields.add("*");             query.returngeometry = true;             query.where = "cis_metr '%" + queryparameterstextbox.text + "%' or comments '%" + queryparameterstextbox.text + "%'";             query.outspatialreference = mymap.spatialreference;                            querytask.executeasync(query);            }          // draw results when query complete         private void generalquerytask_executecompleted(object sender, esri.arcgis.client.tasks.queryeventargs args)         {             // clear previous results             querydatagrid.visibility = visibility.visible;             graphicslayer graphicslayer = mymap.layers["queryresults"] graphicslayer;             graphicslayer.cleargraphics();              // check new results               featureset featureset = args.featureset;             bool isexceedtransferlimit = args.exceededtransferlimit;              try             {                 if (featureset.features.count > 0 && isexceedtransferlimit == false)                 {                     // add results map                     foreach (graphic resultfeature in featureset.features)                     {                         //resultfeature.symbol = resultsfillsymbol;                         graphicslayer.graphics.add(resultfeature);                     }                 }                 else                 {                     messagebox.show("no features found");                 }              }             catch (exception e)             {                 messagebox.show(e.message);             }         }          // notify when query fails         private void generalquerytask_failed(object sender, taskfailedeventargs args)         {             messagebox.show("query failed: " + args.error);         }          private void progresschanged(object sender, progresschangedeventargs e)         {             this.progresstextbox.content = (e.progresspercentage.tostring() + "%");         } 

i know logic off in this, clueless on how fix it. have referred http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(v=vs.95).aspx how use class, information provided not specific situation. wanting do:

when user clicks search button, run query. works perfectly. problem when runs generalquerytask_executecompleted contextswitchdeadlock message if there large amount of records. leaves ui unresponsive.

from have read need put:

if (worker.cancellationpending == true) {     e.cancel = true;     break; } 

where time consuming task takes place. problem there no overloaded method me able querytask , backgroundworker. appreciated. if need more information, please let me know.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -