Skip to content

Objects not being correctly disposed. #1

Description

@ArtWDrahn

Sometimes when closing the game we get an unhandled exception in MainForm.Tick when invoking Action. Unclear at this point what is calling the method.

Specifically this line of code:

        this.Invoke((Action)(() =>
        {
            canvas.Image = e.Frame;
        }));

Exception Data:
System.ObjectDisposedException was unhandled
HResult=-2146232798
Message=Cannot access a disposed object.
Object name: 'MainForm'.
Source=System.Windows.Forms
ObjectName=MainForm
StackTrace:
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at System.Windows.Forms.Control.Invoke(Delegate method)
at OpenMario.MainForm.Tick(FrameEventArgs e) in d:\Dropbox\GitHub\OpenMario\OpenMario\MainForm.cs:line 41
at OpenMario.MainForm.<.ctor>b__0(Object o, FrameEventArgs e) in d:\Dropbox\GitHub\OpenMario\OpenMario\MainForm.cs:line 26
at OpenMario.Core.Engine.Engine.Tick() in d:\Dropbox\GitHub\OpenMario\OpenMario.Core\Engine\Engine.cs:line 86
at OpenMario.Core.Engine.Engine.ThreadRun() in d:\Dropbox\GitHub\OpenMario\OpenMario.Core\Engine\Engine.cs:line 51
at OpenMario.Core.Engine.Engine.b__1() in d:\Dropbox\GitHub\OpenMario\OpenMario.Core\Engine\Engine.cs:line 99
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions