Esempio n. 1
0
        public async Task TestForegroundThread(bool initAgain, bool inBg)
        {
            if (initAgain)
            {
                var current = ForegroundThreadAffinitizedObject.CurrentForegroundThreadData;
                if (inBg)
                {
                    await Task.Run(() => { RoslynService.Initialize(); });
                }
                else
                {
                    RoslynService.Initialize();
                }
                Assert.AreSame(current, ForegroundThreadAffinitizedObject.CurrentForegroundThreadData);
            }

            var obj = new ForegroundThreadAffinitizedObject(false);

            // FIXME: Roslyn does not about Xwt Synchronization context.
            //Assert.AreEqual (ForegroundThreadDataKind.MonoDevelopGtk, obj.ForegroundKind);
            Assert.AreEqual(Runtime.MainTaskScheduler, obj.ForegroundTaskScheduler);
            Assert.IsTrue(obj.IsForeground());

            await Task.Run(() => {
                Assert.IsFalse(obj.IsForeground());
            });

            int x = 0;
            await obj.InvokeBelowInputPriority(() => {
                Assert.IsTrue(obj.IsForeground());
                x++;
            });

            Assert.AreEqual(1, x);

            await Task.Run(() => obj.InvokeBelowInputPriority(() => {
                Assert.IsTrue(obj.IsForeground());
                x++;
            }));

            Assert.AreEqual(2, x);
        }
Esempio n. 2
0
 public Task SetForegroundColorAsync(ZColor color)
 {
     return(foregroundThreadAffinitedObject.InvokeBelowInputPriority(() =>
                                                                     this.fontAndColorService.SetForegroundColor(color)));
 }