Thursday, April 27, 2017

Two Threads printing ABCD sequence one in upper and another in lower

Suppose there is a ABCD.... sequence we want to print this sequence on Two threads. One thread printing in Upper case and another in Lower case without breaking the sequences or order.

Output should look like

A--thread1
a--thread2
B--thread1
b--thread2
C--thread1
c--thread2


Solution Code
 
using System;
using System.Threading;
class Program
{
    static void Main()
    {
        Thread T1 = new Thread(new ThreadStart(Th1));
        Thread T2 = new Thread(new ThreadStart(Th2));
        T1.Start();
        T2.Start();
    }
   
    static void Th1(){
        string str ="ABCDEF"   ;
        foreach(char c in str){
            Console.WriteLine(c.ToString().ToLower());
            Thread.Sleep(1000);
        }
    }
   
    static void Th2(){
        string str ="ABCDEF"   ;
        foreach(char c in str){
            Console.WriteLine(c);
            Thread.Sleep(1000);
        }
    }
}


Output
A
a
B
b
C
c

Sunday, April 23, 2017

ICommand Usage


Below link will explain about the ICommand usage in wpf and also how to implement in MVVM.

Source:



Code Formater

Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code