|
-
Sep 12th, 2005, 11:47 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] delegate callback problem...stack overflow
I am coding a user control. Within the user control I am trying to define a callback. Here is what I have:
//class var (create delegate)
private delegate void sockDelegate(string s);
//in constuctor (init delegate variable)
frmMain fMain = new frmMain();
sockDelegate del = new sockDelegate(fMain.socketClicked);
//when the socket is clicked (button event handler). Call the callback function on frmMain
del("the socket was clicked");
The problem is in the constructor. I have to create an instance of frmMain, but it has an instance of this user control so:
frmMain loads and inits the user control which loads a frmMain which loads a user control whick loads a frmMain....etc....etc until the stack is full.
How can I assign the callback? I would like a code example of a function in the user control that will assign the callback, taking the function as a passed parameter. Something like:
public bool assignCallback(functionName, formInstance){...}
Please help me!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|