示例#1
0
        private static Future <IFuture> WaitForX(IEnumerable <IFuture> futures, int x)
        {
            if (futures == null)
            {
                throw new ArgumentException("Must specify at least one future to wait on", "futures");
            }

            var f = new Future <IFuture>();
            var h = new WaitHandler();

            h.Composite = f;
            h.State.AddRange(futures);
            h.Trigger = x;

            OnComplete oc = h.OnComplete;
            OnDispose  od = h.OnDispose;

            if (h.State.Count == 0)
            {
                throw new ArgumentException("Must specify at least one future to wait on", "futures");
            }

            f.RegisterOnDispose(h.OnCompositeDispose);

            foreach (IFuture _ in futures)
            {
                _.RegisterOnComplete(oc);
                _.RegisterOnDispose(od);
            }

            return(f);
        }
示例#2
0
        protected override void ObservingThread()
        {
            while (true)
            {
                // Wait signal from timer
                WaitHandler.WaitOne();

                // Check if there are any channels to check new content
                Program.Log(Tag, "Checking new videos on channels");
                if (SettingsManager.Config.ChannelList.Count < 1)
                {
                    Program.Log(Tag, "Nothing to check");
                }

                foreach (var chatChannel in SettingsManager.Config.ChannelList)
                {
                    try
                    {
                        // If chat muted, skip it
                        if (SettingsManager.Config.MutedServers.Contains(chatChannel.DiscordChatId))
                        {
                            continue;
                        }
                        //If not YotubeService, skip it
                        if (chatChannel.ServiceType != typeof(YouTubeClient))
                        {
                            continue;
                        }

                        var reflectionSingletonGetter = (IClient)chatChannel.ServiceType.GetMethod("GetInstance")?.Invoke(null, null);
                        var youTubeTask = reflectionSingletonGetter?.GetLast(chatChannel.ServiceChannel);
                        youTubeTask?.Wait();
                        var video = (Video)youTubeTask?.Result;

                        // If video found and not already sent to text chat channel
                        if (video != null && reflectionSingletonGetter.AddLast(chatChannel.DiscordChatId, chatChannel.ServiceChannel, video.Id))
                        {
                            Task <DiscordChannel> discordChatTask = Program.Discord.GetChannelAsync(chatChannel.DiscordChatId);
                            discordChatTask.Wait();

                            var notifyMessage =
                                string.Format(
                                    Resources.Resource.ResourceManager.GetString("youtube-notify-text",
                                                                                 discordChatTask.Result.GetCultureInfo()), video.Author, video.Id);
                            Program.Discord.SendMessageAsync(discordChatTask.Result, notifyMessage);
                            Program.Log(Tag, $"New video for YouTube channel <{video.Author}> found. Sending it to discord chat <{discordChatTask.Result.Name}>");
                        }
                        else
                        {
                            Program.Log(Tag, video == null ? $"No video found or it's null" : $"New YouTube video skipped '{video.Title}'", LogLevel.Debug);
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.Log(Tag, ex, DSharpPlus.LogLevel.Error);
                    }
                }
                Program.Log(Tag, $"All channels checked. \nNext check:{DateTime.Now.AddMilliseconds(SettingsManager.Config.ObserveCheckInterval)}");
            }
        }
示例#3
0
 public GlideData(double framesleft, Vector2 perframe)
     : this()
 {
     this.perframe   = perframe;
     this.framesleft = framesleft;
     waitHandle      = new WaitHandler();
 }
示例#4
0
 public SayData(string text, TimeSpan timeleft, Sprite value)
     : this()
 {
     this.text     = text;
     this.timeleft = timeleft;
     waitHandle    = new WaitHandler();
     this.value    = value;
 }
示例#5
0
        protected sealed override IResult Execute(CancellationToken cancellationToken)
        {
            Log.WriteInformation($"{DisplayName} listening");

            WaitHandler.Wait(() => cancellationToken.IsCancellationRequested);

            return(Result.Success);
        }
示例#6
0
        public void WaitForKey()
        {
            if (Console.IsErrorRedirected || Console.IsOutputRedirected || Console.IsInputRedirected)
            {
                return;
            }

            WaitHandler.Wait(() => Console.KeyAvailable);
            Console.ReadKey(true);
        }
示例#7
0
        public void selectAndSearch()
        {
            driver.FindElement(searchBar).SendKeys(searchText);
            driver.FindElement(searchButton).Click();
            //might need a wait here

            WaitHandler waitHandler = new WaitHandler();

            waitHandler.ExecuteWait(driver, utilBarPrice);
            driver.FindElement(utilBarPrice).Click();
        }
示例#8
0
        // Metodo que devuelva el proceso del login
        public SelectCompanyPage LoginAs(string mail, string password)
        {
            WaitHandler.ElementIsPresent(Driver, MailInput, 15);
            TypeMail(mail);
            WaitHandler.ElementIsPresent(Driver, PasswordInput, 15);
            TypePassword(password);
            WaitHandler.ElementIsPresent(Driver, SubmitButton, 15);
            ClickSubmitButton();

            return(new SelectCompanyPage(Driver));
        }
示例#9
0
        public static void Main()
        {
            {
                SimpleMind.SimpleMind Log         = new SimpleMind.SimpleMind();
                ServiceHost           bone_server = IPCConnection.ServerConnect();
                ServiceFisshBone.Init();

                WaitHandler.Wait();
                bone_server.Close();
                Log.writeLog(SimpleMind.Loglevel.Debug, "FiSSHBoneMain", "FiSSHBone exit.");
            }
        }
示例#10
0
 public void UpdateValues()
 {
     framesleft--;
     if (framesleft <= 0.0)
     {
         if (waitHandle != null)
         {
             waitHandle.Set();
             waitHandle = null;
         }
     }
 }
示例#11
0
        //Esperar que aparezcan el mail input y el botón de Create Account
        public bool WaitForCreateAccountElements()
        {
            WaitHandler searcher = new WaitHandler();

            if (searcher.ElementAvailable(Driver, emailInput) & searcher.ElementAvailable(Driver, createAccountBtn))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#12
0
        public void Cancel()
        {
            if (!IsRunning || mCancel == null)
            {
                return;
            }

            CancellingOverride();

            mCancel?.Cancel();
            WaitHandler.Wait(() => !IsRunning);

            mCancel?.Dispose();
            mCancel = null;

            CancelOverride();
        }
示例#13
0
        public UIItemContainer GetMdiWindowByAutomationId(string id)
        {
            UIItemContainer container = null;

            WaitHandler.WaitUntil(() =>
            {
                try
                {
                    var ele   = window.GetElement(SearchCriteria.ByAutomationId(id));
                    container = new UIItemContainer(ele, HuxleyApplication.MainForm.window.ActionListener);
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }, "cannot find element ");
            return(container);
        }
示例#14
0
        public void WaitForKey(ConsoleKey key, ConsoleModifiers modifiers = default(ConsoleModifiers))
        {
            if (Console.IsErrorRedirected || Console.IsOutputRedirected || Console.IsInputRedirected)
            {
                return;
            }

            WaitHandler.Wait(
                () =>
            {
                if (!Console.KeyAvailable)
                {
                    return(false);
                }

                var interceptedKey = Console.ReadKey(true);
                return
                (interceptedKey.Key == key &&
                 interceptedKey.Modifiers == modifiers);
            });
        }
示例#15
0
 public void Init(CommandDelegate command, TimeSpan delay)
 {
     Cancel();
     if (delay != TimeSpan.MinValue)
     {
         Delay = delay;
     }
     _timer = new Timer(o => {
         if (IsRunning)
         {
             return;
         }
         TimerErrorException tex = null;
         try {
             WaitHandler.Reset();
             IsRunning = true;
             command();
             if (_period == infinity)
             {
                 Cancel();
             }
         } catch (Exception exc) {
             if (Error != null)
             {
                 Error(this, tex = new TimerErrorException(exc));
             }
         } finally {
             IsRunning = false;
             try {
                 WaitHandler.Set();
             } catch { }
             if (tex == null || !tex.CancelFinishedEvent)
             {
                 RaiseFinished();
             }
         }
     },
                        null, Delay, _period);
 }
示例#16
0
        protected override void JobThread(CancellationToken token)
        {
            var position = 0;

            while (_nextCheck.IsNext(position))
            {
                token.ThrowIfCancellationRequested();

                var readingPart = _queue.Next();
                if (readingPart == null)
                {
                    WaitHandler.WaitOne();
                    continue;
                }

                WaitHandler.Set();

                var bytes = readingPart.Data;
                _writer.Write(bytes);

                position++;
            }
        }
示例#17
0
        protected override void JobThread(CancellationToken token)
        {
            var index = 0;

            while (Reader.LeftBytes > 0)
            {
                token.ThrowIfCancellationRequested();

                if (_queue.Count() > Settings.ThreadPoolSize)
                {
                    WaitHandler.WaitOne();
                    continue;
                }

                WaitHandler.Set();

                var bytes = Read();
                _queue.Add(index, bytes);

                index++;
            }

            _count = index;
        }
 public void SetError(string error)
 {
     IsError      = true;
     ErrorMessage = error;
     WaitHandler.Set();
 }
 public void SetResponse(object response)
 {
     Response = response;
     WaitHandler.Set();
 }
示例#20
0
        protected sealed override IResult Execute(CancellationToken cancellationToken)
        {
            WaitHandler.Wait(() => cancellationToken.IsCancellationRequested);

            return(Result.Success);
        }
 protected override void DoAck(RabbitMQ.Client.Events.BasicDeliverEventArgs basicDeliverEventArgs, IBasicConsumer subscriptionInfo)
 {
     base.DoAck(basicDeliverEventArgs, subscriptionInfo);
     WaitHandler.Set();
 }
 protected override void WhenChannelShutdown(object sender, ShutdownEventArgs reason)
 {
     base.WhenChannelShutdown(sender, reason);
     WaitHandler.Set();
 }
示例#23
0
        private static async Task <bool> Main()
        {
            OracleFateManager.ForceUpdateGameCache();

            if (OracleFateManager.FateDatabase == null)
            {
                await LoadOracleDatabase.Main();
            }

            if (Poi.Current == null)
            {
                Poi.Current = new Poi(Vector3.Zero, PoiType.None);
                return(false);
            }

            if (Poi.Current.Type == PoiType.Death || Core.Player.IsDead)
            {
                if (Poi.Current.Type == PoiType.Death || Core.Player.IsDead)
                {
                    Logger.SendLog("We died, attempting to recover.");
                }

                if (Poi.Current.Type != PoiType.Death)
                {
                    Poi.Current = new Poi(Core.Player, PoiType.Death);
                }

                return(false);
            }

            await ChocoboHandler.HandleChocobo();

            if (Poi.Current.Type == PoiType.Kill)
            {
                await CombatHandler.HandleCombat();

                return(false);
            }

            if (OracleInventoryManager.ShouldRestockGreens())
            {
                await RestockGysahlGreens.HandleRestockGyshalGreens();

                return(false);
            }

            switch (ModeSettings.Instance.OracleOperationMode)
            {
            case OracleOperationMode.FateGrind:
                await FateGrind.HandleFateGrind();

                break;

            case OracleOperationMode.LevelMode:
                await Levelling.HandleLevelling();

                break;

            case OracleOperationMode.MultiLevelMode:
                await MultiLevelling.HandleMultiLevelling();

                break;

            case OracleOperationMode.SpecificFates:
                await SpecificFates.HandleSpecificFates();

                break;

            case OracleOperationMode.AtmaGrind:
                await AtmaGrind.HandleAtmaGrind();

                break;

            case OracleOperationMode.AnimusGrind:
                await AnimusGrind.HandleAnimusGrind();

                break;

            case OracleOperationMode.AnimaGrind:
                await AnimaGrind.HandleAnimaGrind();

                break;

            case OracleOperationMode.YokaiWatchGrind:
                await YokaiWatchGrind.HandleYokaiWatchGrind();

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (Poi.Current.Type == PoiType.Fate || OracleFateManager.CurrentFateId != 0)
            {
                await FateHandler.HandleFate();

                return(false);
            }

            if (Poi.Current.Type == PoiType.Wait)
            {
                await WaitHandler.HandleWait();
            }

            // Always return false to not block the tree.
            return(false);
        }
示例#24
0
        //Esperar que aparezcan el campo Username
        public bool WaitForUsernameBtn(String firstname, String lastname)
        {
            WaitHandler searcher = new WaitHandler();

            return(searcher.ElementAvailable(Driver, By.LinkText(firstname + " " + lastname)));
        }
示例#25
0
        //Esperar que aparezcan el botón SignIn
        public bool WaitForSignOutBtn()
        {
            WaitHandler searcher = new WaitHandler();

            return(searcher.ElementAvailable(Driver, SignOutBtn));
        }
示例#26
0
 //Method to find the place to search on the page
 public void TypePlace(string place)
 {
     Driver.FindElement(PlaceInput).SendKeys(place);
     WaitHandler.ElementIsPresent(Driver, FirstElementPlace, new TimeSpan(0, 0, timeout));
     Driver.FindElement(FirstElementPlace).Click();
 }
 internal protected override void DoAck(BasicDeliverEventArgs basicDeliverEventArgs, IBasicConsumer subscriptionInfo)
 {
     base.DoAck(basicDeliverEventArgs, subscriptionInfo);
     WaitHandler.Set();
 }
示例#28
0
 void IOperation.Wait()
 {
     WaitHandler.Wait(() => IsRunning || IsCompleted);
     WaitHandler.Wait(() => !IsRunning);
 }
示例#29
0
 public HomePage SelectCompanyForLogin()
 {
     WaitHandler.ElementIsPresent(Driver, CompanyButton, 15);
     ClickCompanyButton();
     return(new HomePage(Driver));
 }
 protected override void WhenChannelShutdown(IModel model, ShutdownEventArgs reason)
 {
     base.WhenChannelShutdown(model, reason);
     WaitHandler.Set();
 }