2012-07-05 18 views
2

我開發了一個用C++/wxWidgets編寫的應用程序,該應用程序具有用於腳本和插件的嵌入式.NET運行時。在手動抽取gtk#事件循環時調度空閒事件

我想使用gtk#作爲插件GUI,但由於gtk事件循環沒有啓動(這是windows上的wxWidgets,所以它不使用gtk作爲後端),GUI沒有響應。

這可以通過wxWidgets的空閒處理期間抽事件循環來解決:

public void OnWxWidgetsIdle() 
{ 
    while(Gtk.Application.EventsPending()) 
     Gtk.Application.RunIteration(); 
} 

然而,這似乎並沒有引發GTK#空閒事件,依賴於空閒事件因此GUI窗口小部件,如閃爍文本框中的光標不能正確更新。

有沒有人知道我可以如何強制調度gtk#空閒事件或任何其他解決方案來解決這個問題?

親切的問候,

安德魯病房。

回答

0

使用的單側的空閒處理器:

void Start() 
    { 
    GLib.Idle.Add (new IdleHandler (OnIdleCreateThumbnail)); 
    } 

bool OnIdleCreateThumbnail() 
    { 
    Image img = GetNextImage(); 

    // If no more images remain, stop the idle handler. 
    if (img == null) 
     return false; 

    CreateThumbnail (img, img.ToString() + ".thumbnail"); 

    // There are more images, invoke this routine again on the next Idle moment. 
    return true;   
    } 

參考