An unhandled document exception was

i am writting a video component to output bitmap,i wrote like this:

    protected override void SolveInstance(IGH_DataAccess DA)
         vs.NewFrame+=new NewFrameEventHandler(v_newframe);

    private void v_newframe(object sender, NewFrameEventArgs eventArgs)
            while (ghdoc.SolutionState != GH_ProcessStep.PostProcess || ghdoc.SolutionDepth != 0)
            { }
             var caller = new GH_Document.GH_ScheduleDelegate(update);
            Grasshopper.Instances.ActiveCanvas.Document.ScheduleSolution(1, caller);
   private void update(GH_Document gh)

When this component run,when the NewFrame event is called,the code in callback function will update compoent.
it works fine ,But, when i run 2 of this compoent in a doc in one time for a several minutes ,an error shows:

i guess it must be relate with schedulesolution,but i donnot know how to fix this ,thank you for help!