Пример #1
0
        public async Task InitAsync()
        {
            using (_showProgressInfo.StartInProgress(ProgressInfoName))
            {
                await InitCoreAsync();

                _initialized.Signal();
            }
        }
 /// <summary>
 /// Call this method from the constructor of the base class if an asynchronous intialization is needed.
 /// Invokes the overrideable method InitCoreAsync, and signals completion with the _initialized event
 /// </summary>
 /// <returns>A <see cref="Task" that is completed when the event is signalled/></returns>
 protected async Task InitAsync()
 {
     try
     {
         await InitCoreAsync();
     }
     finally
     {
         _initialized.Signal();
     }
 }
Пример #3
0
        public async Task SignalIsNotSet()
        {
            var  ev        = new AsyncEventSlim();
            bool completed = false;

            Task t1 = Task.Run(async() =>
            {
                await Task.Delay(100);
                await ev.WaitAsync();
                completed = true;
            });

            ev.Signal();
            await Task.Delay(10); // event should not be set at this time

            Assert.False(completed);
        }
Пример #4
0
        public async Task SignalIsSet()
        {
            var  ev        = new AsyncEventSlim();
            bool completed = false;

            Task t1 = Task.Run(async() =>
            {
                await Task.Delay(100);
                await ev.WaitAsync();
                completed = true;
            });

            ev.Signal();
            await t1; // event is set when task completes

            Assert.True(completed);
        }