|
-
Jan 3rd, 2009, 11:03 PM
#1
Thread Starter
Junior Member
Listbox.Invoke Creates Infinite Loop
Hello all, I have a thread pool that calls a function and in the function it checks if invoke is required and if it is, it invokes the function and returns the value. Somehow this is creating an infinite loops and was wondering if you could help me find the problem. Heres my code:
Code:
private delegate string GetComboDelegate();
private string GetCombo()
{
if (lbWordlist.InvokeRequired)
{
return lbWordlist.Invoke(new GetComboDelegate(GetCombo)).ToString();
}
else
{
while ((lbWordlist.Items[tbWordlist.Value - 1].ToString()).IndexOf(':') == -1)
{
tbWordlist.Value += 1;
}
string tmp = lbWordlist.Items[tbWordlist.Value - 1].ToString();
if (tbWordlist.Value == tbWordlist.Maximum)
StopBots = true;
else
tbWordlist.Value += 1;
return tmp;
}
}
tbWordlist is a Trackbar that keeps track of my position in the Listbox.
-
Jan 4th, 2009, 12:30 AM
#2
Re: Listbox.Invoke Creates Infinite Loop
Where are you calling GetCombo from in the first place?
-
Jan 4th, 2009, 12:47 AM
#3
Thread Starter
Junior Member
Re: Listbox.Invoke Creates Infinite Loop
From the sub my thread pool is sent to
-
Jan 4th, 2009, 12:51 AM
#4
Re: Listbox.Invoke Creates Infinite Loop
 Originally Posted by Spilled
From the sub my thread pool is sent to
I get that. Can you show us the code?
-
Jan 4th, 2009, 12:56 AM
#5
Thread Starter
Junior Member
Re: Listbox.Invoke Creates Infinite Loop
Code:
Image Img;
if (!Bot.GetImage(txtCaptcha.Text, out Img))
{
if(StopBots)
UpdateResponse(Info.id, "Bot Done...");
else
ThreadPool.QueueUserWorkItem(new WaitCallback(Begin), new BotData(Info.id, GetCombo(), Info.proxy, Info.url, Info.timeout));
return;
}
-
Jan 4th, 2009, 12:58 AM
#6
Thread Starter
Junior Member
Re: Listbox.Invoke Creates Infinite Loop
Basically it downloads the Image I need, then queue's another work item with the new combo and returns
-
Jan 4th, 2009, 01:33 AM
#7
Re: Listbox.Invoke Creates Infinite Loop
You said that you're calling GetCombo from the method that you're using as the entry point for your new thread. First up, you haven't shown us that method. Secondly, you're showing us code that calls GetCombo from the current thread, NOT the new thread. If that's the only place GetCombo is called then there's no need for delegation. If it's not the only place then please show us the other code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|