This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using System.Collections.Generic; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| namespace Ex01_Console | |
| { | |
| class ThreadDemo | |
| { | |
| public static void Download(string[] urls) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using System.Threading; | |
| class Program | |
| { | |
| static void Main(strin g[] args) | |
| { | |
| Thread t1 = new Thread(MyBackgroundTask); | |
| t1.Start(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using System.Threading; | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| Thread t1 = new Thread(MyBackgroundTask); | |
| Thread t2 = new Thread(MyBackgroundTask); | |
| Thread t3 = new Thread(MyBackgroundTask); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | static void Main(string[] args) | |
| { | |
| Thread t1 = new Thread(MyBackgroundTask); | |
| Thread t2 = new Thread(MyBackgroundTask); | |
| Thread t3 = new Thread(MyBackgroundTask); | |
| t1.Start("X"); | |
| t2.Start("Y"); | |
| t3.Start("Z"); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| new SharedStateDemo().Run(); | |
| Console.ReadLine(); | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class SharedStateDemo | |
| { | |
| private int itemCount = 0; | |
| private object locker = new Object(); // 用於獨佔鎖定的物件 | |
| public void Run() | |
| { | |
| var t1 = new Thread(AddToCart); | |
| var t2 = new Thread(AddToCart); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using System.Threading; | |
| namespace Ex05_BackgroundThread | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| Thread t = new Thread(MyWork); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | void GetDefaultPaperSize() | |
| { | |
| var devMode = PInvoke.PrinterHelper.GetPrinterDevMode(null); | |
| string s = String.Format("{0} : {1} x {2}", devMode.dmPaperSize, devMode.dmPaperWidth, devMode.dmPaperLength); | |
| Console.WriteLine(s); | |
| } | |
| void SetDefaultPaperSize() | |
| { | |
| string formName = "User defined"; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | private byte[] ReadBlob(int id) | |
| { | |
| byte[] result = null; | |
| var conn = new SqlConnection("Your connection string"); | |
| conn.Open(); | |
| string sql = String.Format("select Photo from MyTable where ID={0}", id); | |
| var cmd = conn.CreateCommand(); | |
| cmd.CommandText = sql; | |
| var reader = cmd.ExecuteReader(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using System.Collections.Generic; | |
| using System.Drawing; | |
| using System.Drawing.Drawing2D; | |
| using System.Linq; | |
| using System.Text; | |
| namespace HuanlinLib.Drawing | |
| { | |
| public enum ExifOrientations | 
OlderNewer