private void InsertRecord(DirectoryRecord record)
        {
            // add value to directory
            lock (_directory) {
                _directory[record.Name] = record;
            }

            // check if value has an expiration time
            if (record.HasExpiration)
            {
                TimerFactory.New(record.Expiration, OnExpire, record.Name, TaskEnv.New());
            }

            SaveToFileSystem(record.Name, record.Value);

            // notify event channel
            XDoc notify = new XDoc("insert").Attr("name", record.Name);

            if (record.HasExpiration)
            {
                notify.Attr("expire", record.Expiration);
            }
            notify.Add(record.Value);
            _events.Post(notify, new Result <DreamMessage>(TimeSpan.MaxValue));
        }
Exemple #2
0
 public void InitializeTests()
 {
     _target = new TimerFactory
     {
         TimerCallback = TimerCallback
     };
 }
Exemple #3
0
        protected override void DefaultValues()
        {
            base.DefaultValues();

            this.maxRotation  = MathHelper.ToRadians(20);
            this.inputManager = WaveServices.Input;
            this.timerFactory = WaveServices.TimerFactory;
            this.soundManager = WaveServices.GetService <SoundManager>();
        }
        protected override void DefaultValues()
        {
            base.DefaultValues();

            this.maxRotation = MathHelper.ToRadians(20);
            this.inputManager = WaveServices.Input;
            this.timerFactory = WaveServices.TimerFactory;
            this.viewportManager = WaveServices.ViewportManager;
            this.soundManager = WaveServices.GetService<SoundManager>();
        }
        public App()
        {
            InitializeComponent();

            var          letterPairGeneratorFactory = new InternalLetterPairGeneratorFactory();
            var          timerServiceFactory        = new TimerFactory();
            IGameService gameService = new GameServiceFactory(letterPairGeneratorFactory, timerServiceFactory).Create();

            MainPage = new NavigationPage(new HomePage(gameService));
        }
        public ThresholdTraceListener(ILoggerFactory loggerFactory, ThresholdOptions options)
        {
            var thresholdOptions1 = options;
            var logger            = loggerFactory.CreateLogger <RequestTracer>();

            _timer = TimerFactory.CreateWithFlowSuppressed(GenerateAndLogReport, logger, thresholdOptions1.EmitInterval, thresholdOptions1.EmitInterval);
            ThresholdServiceQueue.SetSampleSize((int)thresholdOptions1.SampleSize);//change to uint

            _serviceThresholds = options.GetServiceThresholds();
            Start();
        }
    protected override void Awake()
    {
        this.isPersistent = false;
        base.Awake();

        mainCamera = Camera.main;

        this.timer               = TimerFactory.CreateTimer(TimerType.Seconds, 0.01f);
        this.timer.TickEvent    += (float obj) => { ShakeRandom(); };
        this.timer.ElapsedEvent += ReturnPosition;
        this.oldPos              = this.mainCamera.transform.localPosition;
    }
        static void Main(string[] args)
        {
            var timer      = new Timer();
            var connection = new NetworkStatusConnection(
                new HttpNetworkClient(new HttpClient()), new Uri("https://www.google.com"));
            var sensor       = new ConnectionSensor(connection);
            var timerFactory = new TimerFactory();
            var repository   = new ReadingsRepository();
            var scheduler    = new ReadScheduler(timerFactory, repository);

            var scheduledReadings = scheduler.ScheduleReadings(sensor, 15);

            System.Console.ReadKey();
        }
        public TabitTimecodeListener(InputDevice midiIn, int midiChannel)
        {
            MidiIn       = midiIn;
            MidiChannel  = midiChannel;
            NoteReceiver = new NoteTimecodeReceiver();

            Timer        = TimerFactory.Create();
            Timer.Mode   = TimerMode.Periodic;
            Timer.Period = 10;
            Timer.Tick  += Timer_Tick;

            MidiIn.StartRecording();
            MidiIn.ChannelMessageReceived += MidiIn_ChannelMessageReceived;
        }
Exemple #10
0
        /// <summary>
        /// pasar al siguiente timer, anula el actual
        /// </summary>
        /// <param name="result"></param>
        public static bool Inquired(MessageSupervisionResult result)
        {
            if (result.IsCompleted)
            {
                return(false);
            }
            result.Syncro.WaitOne();
            var span = result.Sequence[0];

            result.Sequence.RemoveAt(0);
            TimerFactory.Schedule(OnTimeout, result, Convert.ToInt32(span.TotalMilliseconds));
            result.Syncro.Set();
            return(true);
        }
        public void ManualEngineDiscover(string workingDirectory, string executable, List <string> arguments)
        {
            EngineConfiguration configuration = new EngineConfiguration("Manual", executable, "xboard");

            configuration.WorkingDirectory = workingDirectory;
            currentConfiguration           = configuration;
            if (arguments != null)
            {
                foreach (string arg in arguments)
                {
                    configuration.AddArgument(arg);
                }
            }
            DebugMessageLog log          = new DebugMessageLog();
            EngineBuilder   builder      = new EngineBuilder(log, configuration);
            TimerFactory    timerFactory = new TimerFactory();
            XBoardEngine    engine       = (XBoardEngine)builder.Create(timerFactory, playerReady);
        }
Exemple #12
0
        public InformacniQt(IZarizeni zarizeni, short id, IIDGenerator idGenerator, string logDirectory, IAuthenticationDataLayer authenticationDataLayer, IConfigManager configManager,
                            IOrdersInfoService ordersInfoService, CanteenProvider canteenRepository, ScanCardLayout scanCardLayout,
                            CardScannedLayout cardScannedLayout, TimerFactory timerFactory) : base(zarizeni, id, idGenerator, logDirectory, canteenRepository, timerFactory)
        {
            // musim predat Logger pochazeji primo z automatu, abych mel spravne zaznamenany SQL dotazy
            Log4Net.Core.ILogEx dbLog = this.GetDbLog();

            OrdersInfoService = ordersInfoService;
            ordersInfoService.Initialize(dbLog);

            AuthenticationDataLayer = authenticationDataLayer;
            AuthenticationDataLayer.InitLog(dbLog);

            Typ = 202;

            CardScannedLayout = cardScannedLayout;
            ScanCardLayout    = scanCardLayout;
        }
 public MainViewModel(Factories factories, Cloud cloud, TimerFactory timerFactory,
     BackgroundWorkerFactory workerFactory, MealEditingViewModel.BackNavigation mealEditingBackNavigation,
     JournalViewModel journal, ProductListingViewModel productListing, MealItemEditingViewModel mealItemEditing,
     MessageDialog messageDialog, WelcomeScreen welcomeScreen, CloudMessages cloudMessages)
 {
     this.factories = factories;
     this.cloud = cloud;
     this.timerFactory = timerFactory;
     this.workerFactory = workerFactory;
     this.mealEditingBackNavigation = mealEditingBackNavigation;
     this.journal = journal;
     this.productListing = productListing;
     this.mealItemEditing = mealItemEditing;
     this.messageDialog = messageDialog;
     this.cloudMessages = cloudMessages;
     WelcomeScreen = welcomeScreen;
     ShareStateProvider();
 }
Exemple #14
0
    public Selector(Transform target, float step = 1.0f, float downClamp = 120.0f, float upClamp = 240.0f)
    {
        this.Target    = target;
        this.Step      = step;
        this.DownClamp = downClamp;
        this.UpClamp   = upClamp;

        this.timer = TimerFactory.CreateTimer(TimerType.EndOfFrame);

        this.timer.ElapsedEvent += MakeStep;
        this.timer.ElapsedEvent += Loop;

        this.triggerEnter         = this.Target.gameObject.GetBehaviour <OnTriggerEnterMessage>();
        this.triggerEnter.action += CollisionEventHandler;

        this.triggerExit         = this.Target.gameObject.GetBehaviour <OnTriggerExitMessage>();
        this.triggerExit.action += OnTriggerExitEventHandler;
    }
        protected void discoverExecutable(string engineDir, string executable)
        {
            string folderName = engineDir.Substring(engineDir.LastIndexOf(Path.DirectorySeparatorChar) + 1);
            //	fire it up to see what variants/features it supports
            EngineConfiguration configuration = new EngineConfiguration(folderName, executable, "xboard");

            configuration.WorkingDirectory = engineDir;
            //	if this directory contains a file named 'variants.txt' we will
            //	automatically pass that in as a command line argument (Sjaak II)
            if (File.Exists(engineDir + @"\variants.txt"))
            {
                configuration.AddArgument("variants.txt");
            }
            currentConfiguration = configuration;
            DebugMessageLog log          = new DebugMessageLog();
            EngineBuilder   builder      = new EngineBuilder(log, configuration);
            TimerFactory    timerFactory = new TimerFactory();
            XBoardEngine    engine       = (XBoardEngine)builder.Create(timerFactory, playerReady);
        }
Exemple #16
0
        public void TimerTest2()
        {
            IPlayer player1 = new Player();
            IPlayer player2 = new Player();

            List <IPlayer> players = new List <IPlayer>
            {
                player1,
                player2
            };

            TimerFactory timerFattory = new TimerFactory();
            ITimer       timer        = timerFattory.EqualTimer(players, 10);

            Assert.Equal(10, (int)timer.GetRemainingTime(player1));
            timer.Start(player1);
            timer.SwitchPlayer(player2);
            Thread.Sleep(2000);
            Assert.Equal(7, (int)timer.GetRemainingTime(player2));
        }
Exemple #17
0
        internal Yield PostEntries(DreamContext context, DreamMessage request, Result <DreamMessage> response)
        {
            if (request.ToDocument().Name != "entry")
            {
                throw new DreamBadRequestException("invalid format");
            }

            // prepare entry
            XAtomEntry entry  = new XAtomEntry(request.ToDocument());
            int        number = System.Threading.Interlocked.Increment(ref _counter);
            XUri       link   = Self.At(number.ToString());

            entry.Id = link;
            entry.AddLink(link, XAtomBase.LinkRelation.Edit, null, 0, null);

            // update feed
            XAtomFeed feed = _feed;

            if (feed != null)
            {
                lock (feed) {
                    feed.Add(entry);
                }
            }
            else
            {
                throw new DreamBadRequestException("not initialized");
            }

            // schedule entry deletion
            double seconds = context.GetParam <double>("ttl", _defaultTTL);

            if (seconds > 0)
            {
                TimerFactory.New(TimeSpan.FromSeconds(seconds), AutoDeletePost, number, TaskEnv.Clone());
            }

            // return updated entry
            response.Return(DreamMessage.Created(link, entry));
            yield break;
        }
        /// <summary>
        /// Starts sending messages over a web socket
        /// </summary>
        /// <param name="message">The message.</param>
        private void Start(WebSocketMessageInfo message)
        {
            var vals = message.Data.Split(',');

            var dueTimeMs = long.Parse(vals[0], UsCulture);
            var periodMs  = long.Parse(vals[1], UsCulture);

            if (vals.Length > 2)
            {
                ParseMessageParams(vals.Skip(2).ToArray());
            }

            var cancellationTokenSource = new CancellationTokenSource();

            Logger.Debug("{1} Begin transmitting over websocket to {0}", message.Connection.RemoteEndPoint, GetType().Name);

            var timer = SendOnTimer ?
                        TimerFactory.Create(TimerCallback, message.Connection, Timeout.Infinite, Timeout.Infinite) :
                        null;

            var state = new TStateType
            {
                IntervalMs     = periodMs,
                InitialDelayMs = dueTimeMs
            };

            var semaphore = new SemaphoreSlim(1, 1);

            lock (ActiveConnections)
            {
                ActiveConnections.Add(new Tuple <IWebSocketConnection, CancellationTokenSource, ITimer, TStateType, SemaphoreSlim>(message.Connection, cancellationTokenSource, timer, state, semaphore));
            }

            if (timer != null)
            {
                timer.Change(TimeSpan.FromMilliseconds(dueTimeMs), TimeSpan.FromMilliseconds(periodMs));
            }
        }
 private MainViewModel CreateSut(Factories factories = null, Cloud cloud = null,
     TimerFactory timerFactory = null, ProductListingViewModel productListing = null,
     MealItemEditingViewModel mealItemEditing = null, MessageDialog messageDialog = null,
     WelcomeScreen welcomeScreen = null, CloudMessages cloudMessages = null)
 {
     if (factories == null)
         factories = Substitute.For<Factories>();
     if (cloud == null)
         cloud = Substitute.For<Cloud>();
     if (timerFactory == null)
         timerFactory = Substitute.For<TimerFactory>();
     if (productListing == null)
         productListing = new ProductListingViewModel(factories, new BackgroundWorkerSyncFactory());
     if (mealItemEditing == null)
         mealItemEditing = new MealItemEditingViewModel();
     if (messageDialog == null)
         messageDialog = Substitute.For<MessageDialog>();
     if (welcomeScreen == null)
         welcomeScreen = new WelcomeScreenImpl(messageDialog);
     if (cloudMessages == null)
         cloudMessages = new CloudMessages();
     var journal = new JournalViewModel(factories, new BackgroundWorkerSyncFactory(),
         new SugarEditingViewModel());
     return new MainViewModel(factories, cloud, timerFactory, new BackgroundWorkerSyncFactory(),
         new MealEditingViewModel.BackNavigation(), journal, productListing, mealItemEditing, messageDialog,
         welcomeScreen, cloudMessages);
 }
Exemple #20
0
 public void Setup()
 {
     _timerFactory = new TimerFactory();
 }
 public TrialImpl(TimerFactory timerFactory, MessageDialog messageDialog)
 {
     this.timerFactory = timerFactory;
     this.messageDialog = messageDialog;
 }