hi all,
I'm having a few problems whereby my application is hanging when using the
Invoke method of a form's control.
Basically, when a user clicks a button on the form, it calls a remote
function, which in turn fires an event that is caught by the form.
The form then need to add a value passed in the event to a form object,
however, when using the Invoke method, it just hangs.
Here's a snippet of the code;
public void NotifyUserAdded (string username)
{
TreeNodeCollect ion treeNodeCollect ion = treeMachines.No des[0].Nodes;
TreeNode treeNodeParent = treeMachines.No des[0];
AddDelegate addDelegate = new AddDelegate(tre eNodeCollection .Add);
ExpandDelegate expandNodeDeleg ate = new
ExpandDelegate( treeNodeParent. Expand);
treeMachines.In voke(addDelegat e, new object[] {new
TreeNode(userna me,0,0)});
treeMachines.In voke(expandNode Delegate);
}
the two delegates are obviously previously defined.
delegate int AddDelegate(Tre eNode treeNode);
delegate void ExpandDelegate( );
Sometimes it works, but it's very slow. If i take the invoke out and use
the Node.Add method, it works... but obviously not correctly - as 50% of the
time it throws the "must use invoke" exception.
Any ideas?
TIA
Sam Martin