public void Invoke() { var value = 0; var once = new OnceAction(() => value++); var tasks = new[] { Task.Run(() => once.Invoke()), Task.Run(() => once.Invoke()), Task.Run(() => once.Invoke()), }; Task.WaitAll(tasks); Assert.That(value, Is.EqualTo(1)); }
public void Invoke(string obj) { var value = ""; var once = new OnceAction <string>(s => value += s); var tasks = new[] { Task.Run(() => once.Invoke(obj)), Task.Run(() => once.Invoke(obj)), Task.Run(() => once.Invoke(obj)), }; Task.WaitAll(tasks); Assert.That(value, Is.EqualTo(obj)); }
public void Content() { onceBeforeContent.Invoke(); // Do not resize in render, otherwise the queued up Image has an invalid binding id var offset = GetCursorScreenPos(); var size = GetContentRegionAvail(); if (Framebuffer.Width != (uint)size.X || Framebuffer.Height != (uint)size.Y) { Resize(size); } Vector4 normalColor; unsafe { normalColor = *GetStyleColorVec4(ImGuiCol.Button); } PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero); PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero); PushStyleColor(ImGuiCol.ButtonActive, normalColor); PushStyleColor(ImGuiCol.ButtonHovered, normalColor); Image(bindingHandle, size); PopStyleColor(2); PopStyleVar(2); ImGuizmoNET.ImGuizmo.SetRect(offset.X, offset.Y, size.X, size.Y); }
public void Invoke_Twice() => Assert.That(() => { var dummy = 0; var once = new OnceAction(() => dummy++) { IgnoreTwice = false }; var tasks = new[] { Task.Run(() => once.Invoke()), Task.Run(() => once.Invoke()), Task.Run(() => once.Invoke()), }; Task.WaitAll(tasks); }, Throws.TypeOf <AggregateException>().And.InnerException.TypeOf <TwiceException>());
public void Invoke() { var dest = 0; var once = new OnceAction(() => dest++); var tasks = 5.Make(i => Task.Run(() => once.Invoke())); Task.WaitAll(tasks.ToArray()); Assert.That(once.Invoked, Is.True); Assert.That(dest, Is.EqualTo(1)); }
public void Invoke_Generics() { var src = "once"; var dest = ""; var once = new OnceAction <string>(s => dest += s); var tasks = 5.Make(i => Task.Run(() => once.Invoke(src))); Task.WaitAll(tasks.ToArray()); Assert.That(once.Invoked, Is.True); Assert.That(dest, Is.EqualTo(src)); }
public void Invoke_Twice() { var dest = 0; var once = new OnceAction(() => dest++) { IgnoreTwice = false }; var tasks = 5.Make(i => Task.Run(() => once.Invoke())); Assert.That(() => Task.WaitAll(tasks.ToArray()), Throws.TypeOf <AggregateException>().And.InnerException .TypeOf <TwiceException>()); Assert.That(dest, Is.EqualTo(1)); }
public void Invoke_Generics_Twice() { var src = "twice"; var dest = ""; var once = new OnceAction <string>(s => dest += s) { IgnoreTwice = false }; var tasks = 5.Make(i => Task.Run(() => once.Invoke(src))); Assert.That(() => Task.WaitAll(tasks.ToArray()), Throws.TypeOf <AggregateException>().And.InnerException .TypeOf <TwiceException>()); Assert.That(dest, Is.EqualTo(src)); }