Esempio n. 1
0
        public void Initialize()
        {
            // Create the SignalR hub context
            _hubContext = GlobalHost.ConnectionManager.GetHubContext <WeatherHub>();

            // Try 5 times to aquire a session
            for (int i = 0; i < 5; i++)
            {
                // Get the session going
                bool result = OneWireSession.Acquire();

                // If successful then break out
                if (result)
                {
                    break;
                }

                // Wait for a little bit
                Thread.Sleep(1000);
            }

            // Hook events for new devices
            OneWireSession.Network.DeviceAdded += HandleDeviceAdded;

            // Load the list of weather devices
            LoadWeatherDevices();

            // Fire the initialized event
            //FireInitialized();
        }
Esempio n. 2
0
        public void Terminate()
        {
            // Fire the terminated event
            //FireTerminated();

            // Make sure the refresh thread has stopped
            StopRefresh();

            // Release the session
            if (OneWireSession != null)
            {
                OneWireSession.Release();
            }

            OneWireSession = null;
        }