Invoking Progressbar
-
Hi, I need to control my progressbar inside a thread by invoking it on GUI thread, otherwise the GUI may lock for a short time which is really disturbing. How can I change the Value property of a progressbar with invoking it. Thanks in advance.
-
Hi, I need to control my progressbar inside a thread by invoking it on GUI thread, otherwise the GUI may lock for a short time which is really disturbing. How can I change the Value property of a progressbar with invoking it. Thanks in advance.
-
Hi, I need to control my progressbar inside a thread by invoking it on GUI thread, otherwise the GUI may lock for a short time which is really disturbing. How can I change the Value property of a progressbar with invoking it. Thanks in advance.
I think you are looking for
Background Worker
:) Have a look into this, It may help you ! Using the BackgroundWorker Component in .NET 2 applications[^]Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET
-
Thank you, that article is perfect.
-
Thank you, that article is perfect.
I'll make sure and tell the author. :-D
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
-
I'll make sure and tell the author. :-D
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
I implemented the solution to my project easily, but there is only one problem. I need to change the enabled property of a ToolStripMenuItem inside a thread and ToolStripMenuItem is not a Control. Therefore, I can't use this method. What can I do?
-
I implemented the solution to my project easily, but there is only one problem. I need to change the enabled property of a ToolStripMenuItem inside a thread and ToolStripMenuItem is not a Control. Therefore, I can't use this method. What can I do?
Use the control that owns the item, so either the ToolStrip or the form. Set up a delegate there that invokes a method that sets the enabled state, and invoke that delegate as you would any other.
Dave
Generic BackgroundWorker - My latest article!
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus) -
Use the control that owns the item, so either the ToolStrip or the form. Set up a delegate there that invokes a method that sets the enabled state, and invoke that delegate as you would any other.
Dave
Generic BackgroundWorker - My latest article!
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)I came up with this, is this a good solution?
public delegate void ControlTSBoolConsumer(ContextMenuStrip cms, ToolStripMenuItem tsmi, bool choice);
private void SetTSEnabled(ContextMenuStrip cms, ToolStripMenuItem tsmi, bool choice)
{
if (cms.InvokeRequired)
cms.Invoke(new ControlTSBoolConsumer(SetTSEnabled), new object[] { cms, tsmi, choice });
else
tsmi.Enabled = choice;
} -
I came up with this, is this a good solution?
public delegate void ControlTSBoolConsumer(ContextMenuStrip cms, ToolStripMenuItem tsmi, bool choice);
private void SetTSEnabled(ContextMenuStrip cms, ToolStripMenuItem tsmi, bool choice)
{
if (cms.InvokeRequired)
cms.Invoke(new ControlTSBoolConsumer(SetTSEnabled), new object[] { cms, tsmi, choice });
else
tsmi.Enabled = choice;
}I expect that to work fine. I am aware the MSDN documentation doesn't say much about this, and neither does my article. I probably should add the following paragraph: There are several items that Visual Designer can add to a Form although they aren't Controls; they are either parts of a Control (e.g. MenuItem, ToolStripMenuItem, ...) or Components (Forms.Timer, SerialPort, ...); for all of these I think a good approach is to choose a Control on which InvokeRequired/Invoke can be used; the Form itself is a good candidate for solving threading unsafety issues. :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!