[英]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.