2016-04-15 43 views
0

我試圖做一個定時器,以預設的時間間隔調用函數。這是迄今爲止的代碼。引用C++/CX中的成員函數

void MainPage::startTimer() 
{ 
    DispatcherTimer^ refreshTimer = ref new DispatcherTimer; 
    refreshTimer->Tick += ref new Windows::Foundation::EventHandler<Platform::Object^>(this, &MainPage::refreshFunc); 
    TimeSpan t; 
    t.Duration = 500; 
    refreshTimer->Interval = t; 
    refreshTimer->Start(); 
} 

void MainPage::refreshFunc(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) 
{ 
    ... 
} 

當我嘗試編譯我得到一個錯誤,指出:

invalid delegate initializer -- function does not match the delegate type 

錯誤指向事件處理程序的第二個參數在此行中(上述4號線):

refreshTimer->Tick += ref new Windows::Foundation::EventHandler<Platform::Object^>(this, &MainPage::refreshFunc); 

我在這裏做錯了什麼?

我使用C++/CX與VS2015社區

+0

讓它'事件處理程序'所以它的事件處理程序相匹配。 –

回答

0

更改第二個參數的類型編譯爲Platform::Object^

void MainPage::refreshFunc(Platform::Object^ sender, Platform::Object^ e) 
相關問題