Exemple #1
0
        void BusResetLoop()
        {
            ManagedBusManager busMgr = new ManagedBusManager();

            List<IntPtr> callbackHandles = new List<IntPtr>();

            // Register bus events
            IntPtr busResetHandle = busMgr.RegisterCallback(OnBusReset, ManagedCallbackType.BusReset, IntPtr.Zero);
            IntPtr busArrivalHandle = busMgr.RegisterCallback(OnBusArrival, ManagedCallbackType.Arrival, IntPtr.Zero);
            IntPtr busRemovalHandle = busMgr.RegisterCallback(OnBusRemoval, ManagedCallbackType.Removal, IntPtr.Zero);

            callbackHandles.Add(busResetHandle);
            callbackHandles.Add(busArrivalHandle);
            callbackHandles.Add(busRemovalHandle);

            // Prevent exit if CTL+C is pressed.
            Console.TreatControlCAsInput = true;

            Console.WriteLine("Press any key to exit...\n");
            ConsoleKeyInfo cki = Console.ReadKey();

            // Unregister bus events
            foreach (IntPtr currHandle in callbackHandles)
            {
                busMgr.UnregisterCallback(currHandle);
            }
        }
        void BusResetLoop()
        {
            ManagedBusManager busMgr = new ManagedBusManager();

            List <IntPtr> callbackHandles = new List <IntPtr>();

            // Register bus events
            IntPtr busResetHandle   = busMgr.RegisterCallback(OnBusReset, ManagedCallbackType.BusReset, IntPtr.Zero);
            IntPtr busArrivalHandle = busMgr.RegisterCallback(OnBusArrival, ManagedCallbackType.Arrival, IntPtr.Zero);
            IntPtr busRemovalHandle = busMgr.RegisterCallback(OnBusRemoval, ManagedCallbackType.Removal, IntPtr.Zero);

            callbackHandles.Add(busResetHandle);
            callbackHandles.Add(busArrivalHandle);
            callbackHandles.Add(busRemovalHandle);

            // Prevent exit if CTL+C is pressed.
            Console.TreatControlCAsInput = true;

            Console.WriteLine("Press any key to exit...\n");
            ConsoleKeyInfo cki = Console.ReadKey();

            // Unregister bus events
            foreach (IntPtr currHandle in callbackHandles)
            {
                busMgr.UnregisterCallback(currHandle);
            }
        }
 private void CameraSelectionWindowClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         m_busMgr.UnregisterCallback(m_busResetHandle);
     }
     catch (FC2Exception ex)
     {
         BasePage.ShowErrorMessageDialog("Error unregistering callback.", ex);
     }
 }