BrianPeek.com

A Compendium of Random Uselessness
in Search

Invoke or BeginInvoke problem.

Last post Thu, Jul 24 2008 3:14 PM by Caio. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • Wed, Jul 23 2008 9:56 PM

    Invoke or BeginInvoke problem.

    Hi! I'm trying to integrate XNA and the Wiilib. I started creating a new XNA Game project and them mixing the example provided in the library within the game project. I have added on my Game.cs almost the same code that exist in MultipleWiimoteForm.cs. Besides that I created the WiimoteInfo class, which is pratically the same as the one provided except that I removed all components. The idea is to have the skeleton of things on my Game. I could compile everything successfully but when I run the Game I receive: System.InvalidOperationException was unhandled Message="Invoke or BeginInvoke cannot be called on a control until the window handle has been created." Source="System.Windows.Forms" StackTrace: at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[ args, Boolean synchronous) at System.Windows.Forms.Control.BeginInvoke(Delegate method, Object[ args) at XAnimationTest.WiimoteInfo.UpdateState(WiimoteChangedEventArgs args) in C:\Documents and Settings\Server\Desktop\Caio\XAnimationTest\XAnimationTest\WiimoteInfo.cs:line 38 at XAnimationTest.Game1.wm_WiimoteChanged(Object sender, WiimoteChangedEventArgs e) in C:\Documents and Settings\Server\Desktop\Caio\XAnimationTest\XAnimationTest\XAnimationTest\Game1.cs:line 352 at WiimoteLib.Wiimote.OnReadData(IAsyncResult ar) at System.IO.FileStream.AsyncFSCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) InnerException: How can I fix this? Regards,
  • Thu, Jul 24 2008 2:42 AM In reply to

    Re: Invoke or BeginInvoke problem.

    You shouldn't need to use Invoke/BeginInvoke within XNA...just call the methods directly.
  • Thu, Jul 24 2008 9:46 AM In reply to

    • Caio
    • Top 10 Contributor
      Male
    • Joined on Thu, Jun 12 2008
    • São Paulo, SP
    • Posts 19

    Re: Invoke or BeginInvoke problem.

    That was me who posted the topic above.

    Instead of:

    BeginInvoke(new UpdateWiimoteStateDelegate(UpdateWiimoteChanged), args);

    Should I call only UpdateWiimoteChanged this way:

    UpdateWiimoteChanged(args);

    ?

    If so, should I remove the delegate(s) declaration which is on top of WiimoteInfo.cs (see below) ?

    private delegate void UpdateWiimoteStateDelegate(WiimoteChangedEventArgs args);
    private delegate void UpdateExtensionChangedDelegate(WiimoteExtensionChangedEventArgs args);

    Thanks in advance,

  • Thu, Jul 24 2008 10:55 AM In reply to

    Re: Invoke or BeginInvoke problem.

    That is correct.
  • Thu, Jul 24 2008 3:14 PM In reply to

    • Caio
    • Top 10 Contributor
      Male
    • Joined on Thu, Jun 12 2008
    • São Paulo, SP
    • Posts 19

    Re: Invoke or BeginInvoke problem.

     Thank you very much!

Page 1 of 1 (5 items)
Copyright (C) 2008 Brian Peek
Powered by Community Server (Commercial Edition), by Telligent Systems