Application/C#

C# :: Delegate void return

나비:D 2008. 3. 31. 15:57

delegate string GetTextCallback();
public string GetText()
{
    if (this.cb_DataSelectTime.InvokeRequired)
    {
        GetTextCallback callback = new GetTextCallback(GetText);
        return (string) this.Invoke(callback, new object[] { });
    }
    else
    {
        return this.cb_DataSelectTime.Text;
    }
}

delegate void SetTextCallback();
public string SetText()
{
    if (this.cb_DataSelectTime.InvokeRequired)
    {
        SetTextCallback callback = new GetTextCallback(SetText);
        return (string) this.Invoke(callback, new object[] { });
    }
    else
    {
        return this.cb_DataSelectTime.Text;
    }
}


일단 Set 과 Get형식의 델리게이트..

UI의 값을 참조시에는 Delegate와 INvokeRequired를 사용하여 호출 해주어야 한다.....

왜?? 아직 잘모르겠따 ㅡㅡ;;;;
생각보다 delegate가 먼말인지 모르겠돠 ㅡㅡ;;; 쟁장..