G
Guest
I know that this is a common problem, but I'm having trouble using Invoke to
cross to the UI thread on a CF 2.0 application. My problem doesn't fit the
typical problem associated with accessing controls though. When my event
fires from the non-UI thread, I check InvokeRequired, and if true, call the
same event again. This time, InvokeRequired should be false and the logic
should execute.
If I call the method from the UI thread (i.e. a button click event)
InvokeRequired is false and all is well. If I call from a non-UI thread (an
Intel Mobile SDK power event) InvokeRequired returns true, I can trace to the
Invoke line, but the debugger never indicates that the method is actually
invoked. Any thoughts?
private void PowerEventHandler(Event e)
{
// Events occur on non-UI thread
if (this.InvokeRequired)
{
this.Invoke(powerChangeObserver.NotifyDelegate, new object[]
{ e });
return;
}
UpdatePowerInfo();
}
private void UpdatePowerInfo()
{
if (myPower.Source.GetValue() == SourceEnum.External)
powerLabel.Text = "AC";
else
powerLabel.Text = "Battery";
}
cross to the UI thread on a CF 2.0 application. My problem doesn't fit the
typical problem associated with accessing controls though. When my event
fires from the non-UI thread, I check InvokeRequired, and if true, call the
same event again. This time, InvokeRequired should be false and the logic
should execute.
If I call the method from the UI thread (i.e. a button click event)
InvokeRequired is false and all is well. If I call from a non-UI thread (an
Intel Mobile SDK power event) InvokeRequired returns true, I can trace to the
Invoke line, but the debugger never indicates that the method is actually
invoked. Any thoughts?
private void PowerEventHandler(Event e)
{
// Events occur on non-UI thread
if (this.InvokeRequired)
{
this.Invoke(powerChangeObserver.NotifyDelegate, new object[]
{ e });
return;
}
UpdatePowerInfo();
}
private void UpdatePowerInfo()
{
if (myPower.Source.GetValue() == SourceEnum.External)
powerLabel.Text = "AC";
else
powerLabel.Text = "Battery";
}