开发者

C# - Updating Panel on UI from different DLL's

I have a GUI that has behind it an interface that 开发者_如何学编程allows those dll's meeting it's contract to run through this GUI. All the work and calculation is done within each dll.

I want to display an update as each record (within the dll) is processed, this update has to be on the GUI.

Is there a simple way of passing this information from the dll, as effectively they don't know what controls are on the GUI.

Thanks.


You can use a callback function that lets the dll libraries inform your GUI when something changes.

For example you can have a delegate like this

delegate void NotifyChange(string action,string whatHasChanged);

Then you can change the methods in your libraries that accept a delegate:

void Porcess(....,NotifyChange notifyChange)
{
...

}

then you can call the callback function in your dll whenever you want to notify that something has changed:

...
if(notifyChange!=null)
notifyChange(thisAction,whatHappened);
...

and you can have an implementation for this delegate in your GUI to pass it to your methods.Instead of using a delegate you can use an interface.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜