Exemple #1
0
            public override void Run()
            {
                Priority += 1;
                try
                {
                    while (!stop.Get())
                    {
                        try
                        {
                            outerInstance.CheckCommonSuggestions(reader);

                            Thread.Sleep(10);// don't starve refresh()'s CPU, which sleeps every 50 bytes for 1 ms
                        }
                        catch (AlreadyClosedException /*e*/)
                        {
                            return;
                        }
                        catch (Exception e)
                        {
                            e.printStackTrace();
                            error = e;
                            return;
                        }
                    }
                }
                finally
                {
                    terminated = true;
                }
            }
Exemple #2
0
            public override void Run()
            {
#if FEATURE_THREAD_PRIORITY
                Priority += 1;
#endif
                try
                {
                    while (!stop)
                    {
                        try
                        {
                            outerInstance.CheckCommonSuggestions(reader);

                            Thread.Sleep(10);// don't starve refresh()'s CPU, which sleeps every 50 bytes for 1 ms
                        }
                        catch (ObjectDisposedException /*e*/)
                        {
                            return;
                        }
                        catch (Exception e)
                        {
                            e.printStackTrace();
                            error = e;
                            return;
                        }
                    }
                }
                finally
                {
                    terminated = true;
                }
            }
Exemple #3
0
            public void Run()
            {
                try
                {
                    // Was cancellation already requested?
                    if (cancellationToken.IsCancellationRequested)
                    {
                        if (Verbose)
                        {
                            Console.WriteLine("Task {0} was cancelled before it got started.",
                                              taskNum);
                        }
                        cancellationToken.ThrowIfCancellationRequested();
                    }

                    while (!stop)
                    {
                        try
                        {
                            outerInstance.CheckCommonSuggestions(reader);
                        }
                        catch (Exception e) when(e.IsAlreadyClosedException())
                        {
                            return; // LUCENENET: In Java, this was the "safe" shutdown signal, however in .NET we are shutting down proactively using AtomicBoolean stop
                        }
                        catch (Exception e) when(e.IsThrowable())
                        {
                            e.printStackTrace();
                            error = e;
                            return;
                        }
                        if (cancellationToken.IsCancellationRequested)
                        {
                            if (Verbose)
                            {
                                Console.WriteLine("Task {0} cancelled", taskNum);
                            }
                            cancellationToken.ThrowIfCancellationRequested();
                        }
                    }
                }
                finally
                {
                    terminated = true;
                }
            }