C#.Rihter.ParentTasks

Example

static void Main(string[] args) { Task<Int32[]> parent = new Task<Int32[]>(() => { var results = new Int32[3]; StartNewTask(results, 0, 1); StartNewTask(results, 1, 2);

Читать на сайте автора.

C#.Rihter.ContinueWith

static void Main(string[] args) { Task<int> t = new Task<int>(Work); t.Start(); Thread.Sleep(3000); // doing smth in main thread t.ContinueWith(t => Console.WriteLine(«job is done «

Читать на сайте автора.

C#.Rihter.Task

task allows get result

static void Main(string[] args) { Task<int> t = new Task<int>(n => Sum((int) n), 10000); t.Start(); t.Wait(); Console.WriteLine(«The sum is «

Читать на сайте автора.

C#.Rihter. How to stop thread work ? Cancellation token

how do i exit from thread

static void Main(string[] args) { var tokenSource = new CancellationTokenSource(); ThreadPool.QueueUserWorkItem(o => ThreadWorker(tokenSource.Token, 1000)); Console.WriteLine(«Press <Enter> to cancel

Читать на сайте автора.

C#. Rihter. Use Thread from the thread pool

static void Main(string[] args) { Console.WriteLine(«this is main thread»); ThreadPool.QueueUserWorkItem(ThreadWorker, 123); Thread.Sleep(3000); } private static void ThreadWorker(object obj) { Thread.Sleep(1000); Console.WriteLine(«hi from thread pool

Читать на сайте автора.

С#. Foreground and Background threads

Foreground and background threads.

If background thread then application will not wait until it is over, in other case it will.

static void

Читать на сайте автора.

C#. Threads simple example

static void Main(string[] args) { Console.WriteLine(«inside thread id » + Thread.CurrentThread.ManagedThreadId); var otherThread = new Thread(ThreadWork); otherThread.Priority = ThreadPriority.Normal; otherThread.Start(5); otherThread.Join(); // wait for

Читать на сайте автора.

JS. Reject vs throw and catch vs rejectHandler

Both, reject and throw can be handled with catch

reject inside promise will be handled by 2-d argument of then, and if it is

Читать на сайте автора.

js. es6 some features

const

const Pi = 3.14;

SCOPING

block-scoped variables

// es 6 for (let i = 0; i < 10; i ++) { let x =

Читать на сайте автора.

Algo. Mult – Sum

Given an integer number n, return the difference between the product of its digits and the sum of its digits. Example 1: Input: n =

Читать на сайте автора.