[英]What is the equivalent C# code for this Canon SDK C++ code snippet?
此C ++代碼的C#等效項是什么?
private:
static EdsError EDSCALLBACK ProgressFunc (
EdsUInt32 inPercent,
EdsVoid * inContext,
EdsBool * outCancel
)
{
Command *command = (Command *)inContext;
CameraEvent e("ProgressReport", &inPercent);
command->getCameraModel()->notifyObservers(&e);
return EDS_ERR_OK;
}
這是出於說明目的的粗略翻譯:
private static void ProgressFunc(uint percent, object context, out bool cancel)
{
Command command = (Command)context;
CameraEvent e = new CameraEvent("ProgressReport", percent);
command.GetCameraModel().NotifyObservers(e);
cancel = false;
}
( EdsError
已更改為void
,因為我們在C#中使用異常而不是錯誤代碼; EDSCALLBACK
被定義為__stdcall
,在這里與此無關;該代碼僅在所有隱含類和方法都存在的情況下才起作用;慣用的C#將使用event
/ EventHandler <T> / EventArgs而不是“ NotifyObservers”方法;我假設您不想與C ++進行任何互操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.