Пример #1
0
 /// <summary>
 /// Returns the queryMaker by read task type (class).
 /// </summary>
 public virtual IQueryMaker GetQueryMaker(ReadTask readTask)
 {
     lock (this)
     {
         // mapping the query maker by task class allows extending/adding new search/read tasks
         // without needing to modify this class.
         Type        readTaskClass = readTask.GetType();
         IQueryMaker qm;
         if (!readTaskQueryMaker.TryGetValue(readTaskClass, out qm) || qm == null)
         {
             try
             {
                 //qm = qmkrClass.newInstance();
                 qm = (IQueryMaker)Activator.CreateInstance(qmkrClass);
                 qm.SetConfig(config);
             }
             catch (Exception e)
             {
                 throw new Exception(e.ToString(), e);
             }
             readTaskQueryMaker[readTaskClass] = qm;
         }
         return(qm);
     }
 }
Пример #2
0
 /// <summary>
 /// StopReading
 /// Terminates NMEA reading process
 /// </summary>
 public void StopReading()
 {
     ReadCancellationTokenSource.Cancel();
     if (null != ReadTask)
     {
         ReadTask.Wait();
         ReadTask = null;
     }
 }
Пример #3
0
        public LocalChannel(LocalServerChannel parent, LocalChannel peer) : base(parent)
        {
            _peer = peer;
            _localAddress = parent.LocalAddress;
            _remoteAddress = peer.LocalAddress;

            Configuration = new DefaultChannelConfiguration(this);
            _shutdownHook = new ShutdownHook(this);
            _readTask = new ReadTask(this);
        }
Пример #4
0
        public LocalChannel(LocalServerChannel parent, LocalChannel peer) : base(parent)
        {
            _peer          = peer;
            _localAddress  = parent.LocalAddress;
            _remoteAddress = peer.LocalAddress;

            Configuration = new DefaultChannelConfiguration(this);
            _shutdownHook = new ShutdownHook(this);
            _readTask     = new ReadTask(this);
        }
Пример #5
0
        public void AttachNetworkStream(NetworkStream stream, Action closeReceiver = null)
        {
            networkStream      = stream;
            this.closeReceiver = closeReceiver;
            LastReceiveTime    = DateTimeOffset.Now.ToUnixTimeMilliseconds();

            readTask?.Stop();
            readTask = new ReadTask(this);
            readTask.Run();
        }
Пример #6
0
 private void DoTask(ReadTask task)
 {
     if (task is TileTask)
     {
         DoTileTask(task as TileTask);
     }
     else
     {
         //DoBandLevelTask(task as BandLevelTask);
     }
 }
Пример #7
0
        /// <summary>
        /// Reads data from the process output
        /// </summary>
        /// <param name="Buffer">The buffer to receive the data</param>
        /// <param name="Offset">Offset within the buffer to write to</param>
        /// <param name="Count">Maximum number of bytes to read</param>
        /// <returns>Number of bytes read</returns>
        public int Read(byte[] Buffer, int Offset, int Count)
        {
            // Fill the buffer, reentering managed code every 20ms to allow thread abort exceptions to be thrown
            Task <int> ReadTask;

            if (FrameworkProcess == null)
            {
                ReadTask = InnerStream.ReadAsync(Buffer, Offset, Count);
            }
            else
            {
                ReadTask = FrameworkProcess.StandardOutput.BaseStream.ReadAsync(Buffer, Offset, Count);
            }
            while (!ReadTask.Wait(20))
            {
                // Spin through managed code to allow things like ThreadAbortExceptions to be thrown.
            }
            return(ReadTask.Result);
        }
Пример #8
0
        void _tileReadWorker_DoWork(object sender, DoWorkEventArgs e)
        {
cntDo:
            while (_taskStack.Count > 0)
            {
                ReadTask task = _taskStack.Pop();
                if (task != null)
                {
                    DoTask(task);
                }
            }
            if (_bandLevelQueue.Count > 0)
            {
                //从等待队列中拿出任务
                Application_Idle(null, null);
                goto cntDo;
            }
            //队列中已经没有任务,异步读取线程退出
            _workerIsFinisehd = true;
        }
Пример #9
0
        /// <summary>
        /// bütün görevleri web servis üzerinden getirir
        /// </summary>
        /// <param name="userName">kullanıcı adı</param>
        /// <param name="type">Task ya da Approval değerlerini alır</param>
        /// <returns></returns>
        public static IList <ZTask> GetTaskList(string userName, string type)
        {
            IList <ZTask> taskList = null;

            try
            {
                ReadTask readTask = new ReadTask();
                var      tasks    = readTask.ZReadTask(userName);

                if (tasks != null && tasks.Length > 0)
                {
                    taskList = tasks.Where(e => e.Type == type).ToList(); //task listesinde type sütunu Task ya da Approval değerleri alabilir
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(taskList);
        }
Пример #10
0
 public LocalChannel() : base(null)
 {
     Configuration = new DefaultChannelConfiguration(this);
     _shutdownHook = new ShutdownHook(this);
     _readTask = new ReadTask(this);
 }
Пример #11
0
 public LocalChannel() : base(null)
 {
     Configuration = new DefaultChannelConfiguration(this);
     _shutdownHook = new ShutdownHook(this);
     _readTask     = new ReadTask(this);
 }