B
Brian H
Hi all...
I'm having an issue trying to implement a callback. I've been working with
Alex F. PowerAwareApp sample. I've modified it so that instead of opening
the login form, I raise an event that the parent form can intercept. I
can't get it to work (MissingMethodException) but I believe I know the
cause, I just don't know how to fix it. In my case, my parent form is
VB.NET, and the class is virtually unchanged from Alex's work, except for
the addition of the delegate.
In the class that handles the WaitForProc, et.al, I have code similar to
(the EventDescription string in the event is simply to test that I can pass
something back):
public delegate void PowerStateChange(object sender, PowerStateEventArgs
e);
public class PowerStateEventArgs : EventArgs
{
public string EventDescription;
public PowerStateEventArgs(string EventDescription)
{
this.EventDescription = EventDescription;
}
}
In the class with WaitForProc, I have:
public event PowerStateChange OnPowerStateChange;
Then in the WaitThreadProc, assuming the condition is meant, I do the
following:
PowerStateEventArgs args = new PowerStateEventArgs("TESTONLY");
OnPowerStateChange(this, args);
If I create a test form (called login) in C# that calls this powerstate
class, all works fine by wiring up:
login.OnPowerStateChange += new PowerStateChange(login_OnPowerStateChange);
The IDE seems to do a good job at "filling in the blanks" and creating the
method.
But I can't get this to work in VB. What is the equivalent of that last
line of code in my parent form such that my VB.NET form correctly gets the
callback?
Thanks,
Brian
I'm having an issue trying to implement a callback. I've been working with
Alex F. PowerAwareApp sample. I've modified it so that instead of opening
the login form, I raise an event that the parent form can intercept. I
can't get it to work (MissingMethodException) but I believe I know the
cause, I just don't know how to fix it. In my case, my parent form is
VB.NET, and the class is virtually unchanged from Alex's work, except for
the addition of the delegate.
In the class that handles the WaitForProc, et.al, I have code similar to
(the EventDescription string in the event is simply to test that I can pass
something back):
public delegate void PowerStateChange(object sender, PowerStateEventArgs
e);
public class PowerStateEventArgs : EventArgs
{
public string EventDescription;
public PowerStateEventArgs(string EventDescription)
{
this.EventDescription = EventDescription;
}
}
In the class with WaitForProc, I have:
public event PowerStateChange OnPowerStateChange;
Then in the WaitThreadProc, assuming the condition is meant, I do the
following:
PowerStateEventArgs args = new PowerStateEventArgs("TESTONLY");
OnPowerStateChange(this, args);
If I create a test form (called login) in C# that calls this powerstate
class, all works fine by wiring up:
login.OnPowerStateChange += new PowerStateChange(login_OnPowerStateChange);
The IDE seems to do a good job at "filling in the blanks" and creating the
method.
But I can't get this to work in VB. What is the equivalent of that last
line of code in my parent form such that my VB.NET form correctly gets the
callback?
Thanks,
Brian