顯示具有 C# 標籤的文章。 顯示所有文章
顯示具有 C# 標籤的文章。 顯示所有文章

2010/6/5

在Visual Studio 中加入ILDASM的分析器

Tool -> External Tool -> Add


Title : ILDASM
Command : C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\ildasm.exe
Argument : $(TargetPath)
Initial directory : [keep empty]


to check :
Use output window
Treat output as Unicode

CIL初心者體驗

想為碩論的程式跟參考的SXM做整合,他奶奶的,CIL真是難搞到爆。

感覺就像回到第一次寫程式一樣,連宣告個 local variable 都戰戰兢兢,不曉得對錯;而且搞最久的地方竟然是因為要 generate dynamic type 時必須另外開一個 Assembly file,然後呢,他奶奶的,這個 file 就像是在不同 namespace 的行為一樣,新的 dynamic type 竟然不能使用預設的 Assembly file 中的 private class。

機車,如果這是直接寫成 code ,老早就被看出來了。莫名其妙的跟 Assembly file 扯上關係,造成我的知識不夠去了解出錯的原因是啥,說不出的討厭,明明就寫了至少四年的程式,感覺像被當新手耍了一樣。

要不是我對 command line 的環境很度覽,加上 garbage collection 實在是 memory management 的救星,他奶奶的,我也不想再多學一種新語言,多研究演算法才是王道阿。

2010/1/12

回傳 this.variable 和 base.property.get 的方式



假設有繼承 A 的兩個 class,B 與 C,使用宣告在 class 中的 field 與 繼承來的 field,呼叫的方式不一樣在哪?

宣告在 class 中的 field : load field
繼承來的 field : call parent instance

    public class A
    {
        int a;
        public int Value
        {
            get { return a; }
        }
    }

    public class B : A
    {
        int b;
        public int Value
        {
            // IL_0002:  call       instance int32 ConsoleApplication4.A::get_Value()
            get { return base.Value; }
        }
    }

    public class C : A
    {
        int c;
        public int Value
        {
            // IL_0002:  ldfld      int32 ConsoleApplication4.C::c
            get { return this.c; }





            //  throw exception : stack overflow
            //  get{return this.Value; }
        }     }

2009/9/3

C# 逼逼聲

來源 MSDN Link

Console.Beep() : 使用 PCSpeaker, 不經過音效卡
System.Media.SystemSounds.Beep.Play() : 使用音效卡

SystemSounds的種類 :

Asterisk (燒完光碟時聽到)
Beep (點到不可以點的地方)
Exclamation (打開東西時?)
Hand
Question (沒聲音@@)

2009/7/28

Threadsafe events

http://www.codeproject.com/Articles/37474/Threadsafe-Events.aspx

想做一個功能,很多個thread在不同時間會發出一個event,這些event都由同一個event handler來處理。

因為擔心這樣做不是thread-safe,到處找了很久,在codeproject上找到的這篇是我看到整理最清楚剛好提供了我想知道的資訊。

讀完後的心得:不要在raise event後,讓event handlers有機會離開。

因此有機會出錯的情況是很多個event handler對一個raised event,而很多個raised event對一個event handler則沒有這個問題;另外很多個raised event在event handler內處理時會被block住,一次只處理一個raised event。

2008/11/6

ViewportHeight, ExtentHeight, VerticalOffset

因為想做一個功能是可以讓我在看 list 中的資料時,
不會因為 list 正在更新就一直被 scroll 到最新的資料,
同時也想在 scroll 到最底時可以一直看到最新的資料,
一個辦法是偵測scroll bar 有沒有置底,
前提是 list 有長到 scroll bar 出現

ViewportHeight + VerticalOffset(Scroll 到最底) = ExtentHeight

使用這個就可以判斷了 (筆記