3 Replies Latest reply on May 11, 2006 11:15 AM by tonyhigham

    C# Program Using Flash 8 ActiveX Control Will Not Exit Properly

    bward99
      Hello,

      Our Flash 8 application runs inside of a custom C# container and uses the Flash 8 ActiveX control.

      I am having an issue with getting this program to exit cleanly. I use the ExternalInterface.call() to pass an "exit" command to my C# code, and in that code I do a regular form Close() call. Since this form is the main form of the C# application, it should cause the program to exit.

      But what I am seeing is this; the main form closes (so my program no longer has any open windows), but the program does not actually terminate. I have seen this before in the past, and it usually means there is an out of process ActiveX control that has not terminated correctly and is therefore keeping the process alive. I suspect that the Flash 8 ActiveX control is the culprit.

      Are there other calls I need to make to the OCX to get it to shutdown properly? I have tried the Stop() and StopPlay() methods, and I've also tried setting the Movie property to a null, but it still does not terminate cleanly.

      Any suggestions?

      Thanks,

      Brad
        • 1. Re: C# Program Using Flash 8 ActiveX Control Will Not Exit Properly
          tonyhigham Level 1
          i do similar work in vb, and so cant offer any c# specific help, but the flash player may freeze while waiting for a callback from an externalinterface call. if you dont have a callback after you make the "exit" command, this might be the problem...
          • 2. Re: C# Program Using Flash 8 ActiveX Control Will Not Exit Properly
            bward99 Level 1
            OK, I figured this problem out. Tony's response got me on the right path. Thanks Tony!

            What I had originally was code that would allow the Action Script to send a "Exit" command via the ExternalInterface.call() method. At the C# level for this Exit command, I was doing a form.Close() call to close the form. The form was closing, but the program itself was not exiting (the form that was closed was the main form of the application).

            Apparently the problem is that I was attempting to close the form (which was the parent container of the Flash 8 ActiveX control) while Action Script logic was blocking on its call into my C# code. That's apparently a no-no.

            To fix this problem I just added a simple Timer to my C# form. When the "Exit" command is received, it starts that timer then returns (returning control back to the ActionScript). The about 0.2 seconds later the Timer control fires its event, and I do the form.Close() call there. Now the program terminates cleanly.

            Hope this helps.

            Brad
            • 3. Re: C# Program Using Flash 8 ActiveX Control Will Not Exit Properly
              tonyhigham Level 1
              Glad I could help. At the moment I close my forms from the wrapper itself, but if I move that functionality to the flash obj in the future, I will definitely keep this solution in mind...