0

Hey guys,

I've got this code implemented below in my UI form... and calling it from another thread. On debugging the 'else' part throws an TargetParameterCountException...

I'm clueless has to why...

public delegate void SolveDrawMaze(Cell aCell);

        public void SolveDraw(Cell aCell)
        {
            if (InvokeRequired)
            {
                this.BeginInvoke(new SolveDrawMaze(DoMe));
            }
            else
            {
                DoMe(aCell);
            }
        }


        public void DoMe(Cell aCell)
        {
            
        }
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by nick.crane
0

The UI thread cannot be directly accessed by other threads. You have invoke a delegate to perform the changes on the UI.
Theres an example here.

0

I think you should be using Invoke not BeginInvoke.
BeginInvoke is asynchronous and requires an EndInvoke some time later.
You also need to pass the parameters for the Invoked method.

if (InvokeRequired)
            {
                this.Invoke(new SolveDrawMaze(DoMe), new object[] { aCell});
            }

Edited by nick.crane: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.