#pragma warning disable CS0109 // Member does not hide an inherited member; new keyword is not required public new void AddRange(IEnumerable <T> range) { #pragma warning restore CS0109 // Member does not hide an inherited member; new keyword is not required var items = range.ToArray(); if (ItemToBeAdded == null) { //No need to be checked addrange(items); if (ItemAdded != null) { Tasky.Run(() => items.ForEach(item => ItemAdded(item))); } return; } var approved = new List <T>(); foreach (var item in items) { var app = (Bool)true; ItemToBeAdded(item, app); if (app) { approved.Add(item); } } addrange(approved); if (ItemAdded != null) { Tasky.Run(() => items.ForEach(item => ItemAdded(item))); } }
internal Tasky Edit(Tasky editTask) { var data = GetById(editTask.Id); editTask.Body = editTask.Body != null ? editTask.Body : data.Body; return(_repo.Edit(editTask)); }
private void invokeAccessed() { if (ListAccessed != null) { Tasky.Run(() => ListAccessed()); } }
public static async Task <T[]> WhenAll <T>(IEnumerable <Task <T> > tasks) { var t = tasks as Task <T>[] ?? tasks.ToArray(); await Tasky.WhenAll(t); return(t.Select(tt => tt.Result).ToArray()); }
public async Task <IActionResult> PutTasky([FromRoute] Guid id, [FromBody] Tasky tasky) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tasky.Id) { return(BadRequest()); } _context.Entry(tasky).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
internal new void InsertRange(int index, IEnumerable <T> range) { var items = range.ToArray(); if (ItemToBeAdded == null) { //No need to be checked base.InsertRange(index, items); if (ItemAdded != null) { Tasky.Run(() => items.ForEach(item => ItemAdded(item))); } return; } var approved = new List <T>(); foreach (var item in items) { var app = (Bool)true; ItemToBeAdded(item, app); if (app) { approved.Add(item); } } base.InsertRange(index, approved); if (ItemAdded != null) { Tasky.Run(() => items.ForEach(item => ItemAdded(item))); } invokeAccessed(); }
/// <summary> /// Gets a <see cref="Task{TResult}"/> object to represent this ValueTask. It will /// either return the wrapped task object if one exists, or it'll manufacture a new /// task object to represent the result. /// </summary> public Task <TResult> AsTask() { // Return the task if we were constructed from one, otherwise manufacture one. We don't // cache the generated task into _task as it would end up changing both equality comparison // and the hash code we generate in GetHashCode. return(_task ?? Tasky.FromResult(_result)); }
private static void WerFaultHunter(object o) { var stop = o as ThreadStopper; while (true) { if (stop?.Stop == true) { break; } Thread.Sleep(1500); var l = Process.GetProcesses().Where(pp => pp.ProcessName.Contains("WerFault")).ToList(); if (l.Count > 0) { /*foreach (var op in l) { * Console.WriteLine(op.MainWindowTitle); * foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(op)) { * try { * string name = descriptor.Name; * * object value = descriptor.GetValue(op); * Console.WriteLine("{0}={1}", name, value); * } catch {} * } * }*/ Thread.Sleep(4000); Process.GetProcesses().Where(pp => pp.ProcessName.Contains("WerFault")).ToList().ForEach(p => { p.Kill(); Tasky.Run(() => Killed?.Invoke()); //Console.WriteLine($"[WerFault] {p.ProcessName} has been killed."); }); } } _stop = null; }
public new void AddRange(IEnumerable <T> range) { var items = range.ToArray(); if (ItemToBeAdded == null) { //No need to be checked base.AddRange(items); if (ItemAdded != null) { Tasky.Run(() => items.ForEach(item => ItemAdded(item))); } return; } var approved = new List <T>(); foreach (var item in items) { var app = (Bool)true; ItemToBeAdded(item, app); if (app) { approved.Add(item); } } base.AddRange(approved); if (ItemAdded != null) { Tasky.Run(() => items.ForEach(item => ItemAdded(item))); } }
/// <summary> /// Asynchronously waits for this event to be set. /// </summary> public Task WaitAsync(CancellationToken cancellationToken) { lock (_sync) { var ret = _tcs.Task; //Enlightenment.Trace.AsyncManualResetEvent_Wait(this, ret); return(Tasky.Run(() => ret.Wait(cancellationToken))); } }
public static async Task <T> WithYield <T>(this Task <T> task) { var result = await task.ConfigureAwait(false); await Tasky.Yield(); return(result); }
async Task NewTask() { Tasky task = new Tasky(); State.SelectedTask = task; // TODO: sync DataService list with db list await DataService.Save(task); }
private void _start() { if (_hasStarted) { return; } _hasStarted = true; Tasky.Run(() => _sampler((_sampler_canceller = new CancellationTokenSource()).Token)); lastInputInf = new LASTINPUTINFO(); }
private void FireTaskQueued(QueuedTask <T> t) { if (t == null) { throw new ArgumentNullException(nameof(t)); } if (TaskQueued != null) { Tasky.Run(() => TaskQueued?.Invoke(t)); } }
public ActionResult <Tasky> Create([FromBody] Tasky newTask) { try { return(Ok(_ts.Create(newTask))); } catch (Exception e) { return(BadRequest(e.Message)); } }
internal Tasky Edit(Tasky updated) { string sql = @" UPDATE tasks SET body = @Body WHERE id = @Id;"; _db.Execute(sql, updated); return(updated); }
public ActionResult <Tasky> Edit(int id, [FromBody] Tasky editTask) { try { return(Ok(_ts.Edit(editTask))); } catch (Exception e) { return(BadRequest(e.Message)); } }
/// <summary> /// Asynchronously waits for this event to be set. /// </summary> public Task <bool> WaitAsync(int millisecondsTimeout) { lock (_sync) { if (IsSet) { return(Tasky.FromResult(true)); } var ret = _tcs.Task; //Enlightenment.Trace.AsyncManualResetEvent_Wait(this, ret); return(Tasky.Run(() => ret.Wait(millisecondsTimeout))); } }
internal Tasky Create(Tasky newTask) { string sql = @" INSERT INTO tasks (body) VALUES (@CreatorId, @Title); SELECT LAST_INSERT_ID();"; int id = _db.ExecuteScalar <int>(sql, newTask); newTask.Id = id; return(newTask); }
/// <summary> /// Asynchronously waits for this event to be set. /// </summary> public Task <T> WaitAsync(int millisecondsTimeout, CancellationToken cancellationToken) { return(Tasky.Run(() => { var result = _reset.WaitAsync(millisecondsTimeout, cancellationToken).Result; if (result == false) { return default(T); } lock (syncer) { var local = _pointer; return local; } })); }
public static Task <List <IPAddress> > GetConnectableAliases(string _ip, int pingAttempts = 1) { return(Tasky.Run(() => { var ips = GetDnsAliases(_ip).Result; if (ips == null || ips.Count == 0) { return null; } #if !(NET35 || NET3 || NET2) return ips.AsParallel().Where(i => TestHostConnection(i, pingAttempts)).ToList(); #else return ips.Where(i => TestHostConnection(i, pingAttempts)).ToList(); #endif })); #endif }
public static void Cache() { _cacheprogress?.Wait(); _cacheprogress = Tasky.Run(() => { var l = new List <Task>(); foreach (var dist in DistributionManager.GetDistributers(false)) { l.Add(Tasky.Run(() => { foreach (var d in dist.Distributables()) { _randlocdb.Add(d); } })); } Tasky.WhenAll(l.ToArray()).Wait(); _cacheprogress = null; }); }
/// <summary> /// Equalivent to Dns.GetHostAddresses(txt), but returned async. /// </summary> /// <param name="_ip">The IP address</param> /// <returns>List of aliases to this IP</returns> public static Task <List <IPAddress> > GetDnsAliases(string _ip) { if (string.IsNullOrEmpty(_ip)) { return(null); } if (_ip == "localhost" || _ip == "::1") { _ip = "127.0.0.1"; //GetHostAddresses doesn't recognize localhost. } var t = Tasky.Run(() => { try { return(Dns.GetHostAddresses(_ip).ToList()); } catch (Exception) { return(null); } }); return(t); }
public static Task <Task> WhenAny(IEnumerable <Task> tasks) { return(Tasky.WhenAny(tasks)); }
public static Task <Task <TResult> > WhenAny <TResult>(params Task <TResult>[] tasks) { return(Tasky.WhenAny(tasks)); }
public static Task WhenAll(params Task[] tasks) { return(Tasky.WhenAll(tasks)); }
public static Task WhenAll(IEnumerable <Task> tasks) { return(Tasky.WhenAll(tasks)); }
internal Tasky Create(Tasky newTask) { return(_repo.Create(newTask)); }
public static Task <Task <TResult> > WhenAny <TResult>(IEnumerable <Task <TResult> > tasks) { return(Tasky.WhenAny(tasks)); }
public static Task <Task> WhenAny(params Task[] tasks) { return(Tasky.WhenAny(tasks)); }