Posts

Showing posts from 2014

Moving a window to another monitor

I had done this so many times using mouse and every time I did, I wondered why isn't there a key board short cut to do it. Dragging it felt so slow and at times it hindered productivity.
In Windows 7, the short cut key is:   
Win+Shift+left: to move the selected window to left
Win+Shift+right: to move the selected window to right
If you have only two monitors then pressing left or right again will switch the window between the left and right monitors.
I need to test this on more than two monitors. If you have 3 monitors, then let me know how it works.

Task Library: Common Patterns

Creating a new task

void Main() { Console.WriteLine ("I'm the main thread, starting a new task. My ID: " + Thread.CurrentThread.ManagedThreadId); //the task is started immediately Task t = Task.Factory.StartNew(() => { Console.WriteLine ("I'm a task running concurrently with the thread that started me. My ID: " + Thread.CurrentThread.ManagedThreadId); }); Console.WriteLine ("I'm going away. My ID: " + Thread.CurrentThread.ManagedThreadId); }


I'm the main thread, starting a new task. My ID: 20 I'm going away. My ID: 20 I'm a task running concurrently with the thread that started me. My ID: 24

The method Task.Factory.StartNew() creates a task and immediately starts it. If we want to control when a task starts, we can instantiate a new Task object and call Start() on it.

For e.g.

void Main() { Console.WriteLine ("I'm the main thread, starting…