2016年2月14日 星期日

[C#] Windows 多媒體Library 資料

專案須建立一測試程式,並須使用喇叭(WaveOut)、麥克風(WaveIn)作為聲音傳遞使用。

目前使用為函式庫為”winmm.dll” ,window multimedia library 。紀錄一下主要使用函數列表與網站資料。

Multimedia Reference


Waveform Audio Reference

This section lists the functions, structures, and messages associated with waveform audio, which are documented under Multimedia Reference. These elements are grouped as follows.

Auxiliary Devices

Easy Playback

Errors

Opening and Closing

Pitch

Playback Rate

Playback Progress

Playing

Querying a Device

Recording

Retrieving Device Identifiers

Retrieving the Current Position

Sending Custom Messages

Volume


Audio Streaming Sample Code


2016年1月6日 星期三

Test blog on OLW

Test post to Olw

[C#] Thread 傳遞參數

Thread 可以讓一動作於背景持續執行,而不會造成UI 發生凍結(freeze)現象,在多工環境下常常使用的技能。
一般常用的Thread class來自於 System.Threading。通常Thread會搭配一個需要執行的Function。
   1: public void Hello()

   2: {

   3:  Console.WriteLine("Hello World");

   4: }

   5:  

   6: Thread tt = new Thread(new ThreadStart(Hello)); //指派Hello方法

   7: tt.Start(); //開始執行Thread
於第6行,Thread建構式僅接受兩種Class型態。一個就是上面所是的ThreadStart,另一個就是今天的主題ParameterizedThreadStart。
ThreadStart 指定的方法必須為無參數型態,而ParameterizedThreadStart 則可以指定方法夾帶參數,但只限制一個且型態為 object 。因此需要透過轉換型態方式來達到所需要的參數型態。
   1: public void showHello(object obj)

   2: {

   3:     string sz = (string)obj; //unboxing

   4:     Console.WriteLine("Say Hello " + sz + " !!");

   5: }

   6:  

   7: public void Hello()

   8: {

   9:     Thread tt;

  10:     tt = new Thread(new ParameterizedThreadStart(showHello));

  11:     tt.Start("Chris"); //boxing

  12:     Thread.Sleep(2000);

  13:     tt.Abort();

  14: }
其實使用ThreadStart 也是可以傳入參數,只是需要符合其指定的方法必須為無參數型態,因此我們必須使用Class 包裝方式將參數放入其中。
   1: public class PrintHello

   2: {

   3:     public string name;

   4:     public void Hello()

   5:     {

   6:         Console.WriteLine("Hello " + name + " !!");

   7:     }

   8: }

   9:  

  10: public void Hello2()

  11: {

  12:     Thread tt;

  13:     PrintHello p = new PrintHello(); // create class

  14:     tt = new Thread(new ThreadStart(p.Hello)); // use class method

  15:     p.name = "chris";  // configure parameter

  16:     tt.Start();

  17:     Thread.Sleep(2000);

  18:     tt.Abort();

  19: }
以上為C#  Thread 帶入參數應用紀錄

2015年3月11日 星期三

Windows Live Writer with push blogs

首篇文章,利用微軟blog編輯器上傳。

以下為利用WLW使用 Code Snippet外掛呈現經典程式碼

   1: #include <iostream>
   2:  
   3: using namespace std;
   4:  
   5: int main(void)
   6: {
   7:     cout<<" Hello World!! "<<endl;
   8:     
   9:     return 0;
  10: }