Multithreading and ListBox Question


hello, trying multithread listbox has url's in it.

basically trying make each thread make, visit 1 of url's in listbox , request.

i wondering how make each thread make, visit different site in list, not same site?

for example, happens is, if pick 3 threads, 3 threads visit same sites 3 times.

how can if listbox has 3 sites in list, 3 threads visit different site in listbox it'll finish faster, , not same sites?

help appreciated :)

this multithreading code (the code creates threads):

     checkforillegalcrossthreadcalls = false;      var threads = new thread[(int)numericupdown1.value];      (int p = 0; p < (int)numericupdown1.value; p++)      {      threads[p] = (new thread(() => selectall()));      threads[p].start();      }

and here method make each thread go to:

    public void selectall()      {      (int = 0; i< listbox1.items.count;i++)      {      listbox1.setselected(i, true);      checkforillegalcrossthreadcalls = false;      string url = listbox1.selecteditem.tostring();      httpinterface http = new httpinterface();      http.get(url);      messagebox.show(url);      listbox1.clearselected();      }      }

"the handleitem method wrote confusing me because trying call http , not letting me."

what error getting?  is not compiling?  is not running properly?  what's going on?

"also, need let user decide number of threads :/"

if absolutely must specify threads can use threadpool.setminthreads , threadpool.setmaxthread specify number of threads.  if set them both same number know there must many threads.  if it's requirement for app set , done it, know in general should avoid specifying information whenever can avoid it.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'