Example #1
0
        /// <summary>
        /// Method that executes a device process inside a thread.
        /// </summary>
        /// <param name="device"></param>
        private static void UseResource(Device device, int readerCounter, Action <MetaTag> updateUIGridMetaTagsDel)
        {
            if (device is UHFReader)
            {
                #region UHFReader process

                while (onReads)
                {
                    try
                    {
                        readersMutex.WaitOne();

                        if (onReads)
                        {
                            UHFReader.DoInventory(readerCounter, (device as UHFReader), updateUIGridMetaTagsDel);
                        }
                    }
                    finally
                    {
                        if (useDeltaRead)
                        {
                            /// Use TDM delta read duration
                            Thread.Sleep(deltaRead);
                        }

                        readersMutex.ReleaseMutex();
                    }
                }

                #endregion
            }
            else if (device is LaserModule)
            {
                #region Laser process

                usingLasers = true;

                while (onReads)
                {
                    try
                    {
                        dwspcMutex.WaitOne();

                        if (onReads)
                        {
                            LaserModule.DoScanProcess(device as LaserModule);
                        }
                    }
                    finally
                    {
                        dwspcMutex.ReleaseMutex();
                    }
                }

                #endregion
            }
            else if (device is Servo)
            {
                #region Servo process

                usingServo = true;

                while (onReads)
                {
                    try
                    {
                        dwspcMutex.WaitOne();

                        if (onReads)
                        {
                            Servo.DoActionProcess(device as Servo);
                        }
                    }
                    finally
                    {
                        dwspcMutex.ReleaseMutex();
                    }
                }

                #endregion
            }
        }