Friday, 15 April 2011

multithreading - How to wait and get text from another form in multiple backgroundworker -



multithreading - How to wait and get text from another form in multiple backgroundworker -

this form1

public static backgroundworker[] threadarray; //public static autoresetevent[] _eventhandles ; public static readonly object _lockobj = new object(); public static bool _go ; //public static manualresetevent _manualresetevent = new manualresetevent(false); private void backgroundworkerfilesdowork(object sender, doworkeventargs e) { ... lock (_lockobj) { //_manualresetevent.waitone(30000); //_manualresetevent.reset(); //if (clsvaluestatic.captchatext != null) //{ // foreach (var id in clsvaluestatic.captchatext) // { while (!_go) { monitor.wait(_lockobj); } // } //} } ... } private void btn_start_scraping_click(object sender, eventargs e) { servicepointmanager.defaultconnectionlimit = slider_thread.value; threadarray = new backgroundworker[listview_site.items.count]; (var f = 0; f < listview_site.items.count; f++) { threadarray[f] = new backgroundworker(); threadarray[f].dowork += new doworkeventhandler(backgroundworkerfilesdowork); threadarray[f].runworkercompleted += new runworkercompletedeventhandler(backgroundworkerfilesrunworkercompleted); threadarray[f].progresschanged += new progresschangedeventhandler(backgroundworkerfilesprogresschanged); threadarray[f].workerreportsprogress = true; threadarray[f].workersupportscancellation = true; threadarray[f].runworkerasync(listview_site.items[f].tag.tostring()); } }

this form2

private void textboxcaptcha_keydown(object sender, keyeventargs e) { if (e.keycode == keys.enter) { var textbox = sender textboxx; if (textbox != null) { lock (frmscrapinganalysis._lockobj) { //clsvaluestatic.captchatext = null; ////frmscrapinganalysis._go = true; //clsvaluestatic.captchatext.add(textbox.tag.tostring(), textbox.text.trim()); //textbox.parent.parent.dispose(); monitor.pulse(frmscrapinganalysis._lockobj); } //frmscrapinganalysis._manualresetevent.set(); //frmscrapinganalysis._eventhandles[frmscrapinganalysis.positionthread].set(); } } }

this programme login website

form1 have 1 button start multiple backgroundworker , show form2 backgroundworker wait text captcha of textbox form2 my way want when user come in text of backgroundworker shown on form2 backgroundworker released. other backgroundworker still wait i seek code , debug autoresetevent/manualresetevent , monitor.wait()/pulse() , eventwaithandle order execution of backgroundworker fifo 3 days ago, still have not been anyway solve problem :( or other anyway can solve problem. give thanks much

multithreading winforms httpwebrequest backgroundworker

No comments:

Post a Comment