说我有一个公开的一类BeginLongOperation(),并EndLongOperation()用标准的方法开始/结束模式,并实现IDisposable.
它是我的课负责处理一个呼叫Dispose()的通话之间BeginLongOperation()和EndLongOperation()?
如果是这样,这样做的正确方法是什么?
我正在考虑在性能关键应用程序中使用OpenCV,所以我决定从基础开始并测试图像加载速度.令我惊讶的是,与.NET相比,使用OpenCV时,图像加载(我们做了很多事情)需要大约1.5倍.
这是我的代码:
CvDll.cpp
#include "stdafx.h"
#include <opencv2\opencv.hpp>
#define CVDLL_API __declspec(dllexport)
extern "C"
{
CVDLL_API void CvLoadImage(const char* imagePath);
CVDLL_API void CvCreateMat(int width, int height, int stride, int channels, void* pBuffer);
}
CVDLL_API void CvLoadImage(const char* imagePath)
{
cv::Mat image = cv::imread(imagePath, CV_LOAD_IMAGE_UNCHANGED);
}
CVDLL_API void CvCreateMat(int width, int height, int stride, int channels, void* pBuffer)
{
int type = CV_MAKETYPE(CV_8U, channels);
cv::Mat image(cv::Size(width, height), type, pBuffer, stride);
}
Run Code Online (Sandbox Code Playgroud)
Program.cs
static class Cv
{
[DllImport("CvDll.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, …Run Code Online (Sandbox Code Playgroud)