Hello,
To access a memo on my form,I use the following code
public string TextValue
{
set
{
if (this.Memo.InvokeRequired)
{
this.Invoke((MethodInvoker)delegate
{
this.Memo.Text += value + "\n";
});
}
else
{
this.Memo.Text += value + "\n";
}
}
}
I'd like to use the same code to enable/disable my timer,but there's no property InvokeRequired for a timer.
public int Timer
{
set
{
if (this.timer.InvokeRequired) //?? No such thing
{
this.Invoke((MethodInvoker)delegate
{
if (value == 1)
this.timer.Enabled = true;
else
this.timer.Enabled = false;
});
}
else
{
if (value == 1)
this.timer.Enabled = true;
else
this.timer.Enabled = false;
}
}
}
How to enable the timer from a different thread?