Exemple #1
0
        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;
        }
Exemple #2
0
 private void invokeAccessed()
 {
     if (ListAccessed != null)
     {
         Tasky.Run(() => ListAccessed());
     }
 }
        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();
        }
Exemple #4
0
#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)));
            }
        }
Exemple #5
0
        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)));
            }
        }
Exemple #6
0
 /// <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)));
     }
 }
Exemple #7
0
 private void _start()
 {
     if (_hasStarted)
     {
         return;
     }
     _hasStarted = true;
     Tasky.Run(() => _sampler((_sampler_canceller = new CancellationTokenSource()).Token));
     lastInputInf = new LASTINPUTINFO();
 }
Exemple #8
0
 private void FireTaskQueued(QueuedTask <T> t)
 {
     if (t == null)
     {
         throw new ArgumentNullException(nameof(t));
     }
     if (TaskQueued != null)
     {
         Tasky.Run(() => TaskQueued?.Invoke(t));
     }
 }
Exemple #9
0
 /// <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)));
     }
 }
Exemple #10
0
 /// <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;
         }
     }));
 }
Exemple #11
0
        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
        }
Exemple #12
0
        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;
            });
        }
Exemple #13
0
        /// <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);
        }
Exemple #14
0
 public static Task <T> Run <T>(Func <T> func)
 {
     return(Tasky.Run(func));
 }
Exemple #15
0
 public static Task Run(Func <Task> func)
 {
     return(Tasky.Run(func));
 }
Exemple #16
0
 public static Task Run(Action func)
 {
     return(Tasky.Run(func));
 }