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.
Re: Listbox.Invoke Creates Infinite Loop
Where are you calling GetCombo from in the first place?
Re: Listbox.Invoke Creates Infinite Loop
From the sub my thread pool is sent to
Re: Listbox.Invoke Creates Infinite Loop
Quote:
Originally Posted by Spilled
From the sub my thread pool is sent to
I get that. Can you show us the code?
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;
}
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
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.