Showing results 1 to 2 of 2

Thread: V-460 Runtime close event

  1. #1

    Default V-460 Runtime close event

    Hello
    I'm writing my programm on C# which connect to V-460 Runtime and get values of variables. I use Interop.zenOn.dll for it. It work good. Now I want to cautch events in my programm when V-460 Runtime close or reload. Do you have example how to do it.

  2. #2
    Join Date
    28.07.2008
    Posts
    64

    Default Re: V-460 Runtime close event

    If the zenon RT will be closed or a reload will be executed the reference to the COM-Interface will lost (Interop.zenOn.dll). In your case it would be better to check the availability of the Interface cirular.

    You can solve this problem by using the System.Windows.Forms.Timer whith the event handler of the Timer.Tick. With the Tick event handler you can check period of time the interface is still available or not.

    For example:

              if (this.Interface == null)
              {
                  // Check if zenOn is registered in the ROT.
                  try
                  {
                      this.Interface = Marshal.GetActiveObject("zenOn.Application") as
     zenOn.Application;
                      // Time for check the zenOn COM Interface
                      m_cCheckTimer = new System.Windows.Forms.Timer();
                      m_cCheckTimer.Interval = 2000;
                      m_cCheckTimer.Tick += new EventHandler(CheckTimer_Tick);
                      m_cCheckTimer.Start();
                  }
                  catch
                  {
                      this.Interface = null;
                  }
              }



            void CheckTimer_Tick(object sender, EventArgs e)
            {
              Debug.Print("CheckTimer_Tick " + 
                  Thread.CurrentThread.GetApartmentState().ToString() +
               " " + Thread.CurrentThread.ManagedThreadId);
              // Check if Interface available
              if (zenRuntimeCOM.ZenonCOMApplication.IsAppOnline() == false)
              {
                  System.Diagnostics.Trace.WriteLine
    ("CheckTimer_Tick zenOn is abnormal Terminated");
                  this.InvokeEventOnUIThread(
    new EventOnUIThread_Application_OnClose(OnEventOnUIThread_Application_OnClose), null);
              }
            }
    Last edited by tulon : 27th August 2010 at 12:12

Similar Threads

  1. Close "Web-Client" window automatically
    By herberto in forum zenon Network
    Replies: 10
    Last Post: 25th May 2016, 10:42
  2. Event and interlocking in ALC
    By roberto1978 in forum zenon Energy Edition
    Replies: 3
    Last Post: 28th January 2016, 11:13
  3. Drawn event
    By flajoso in forum VBA
    Replies: 5
    Last Post: 26th August 2008, 11:09
  4. Replies: 1
    Last Post: 1st April 2008, 11:58
  5. The event OnElementCreated is not executed
    By markclemens in forum VBA
    Replies: 0
    Last Post: 21st February 2008, 14:31

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •