public void SetRelease(ViewDataCallback viewDataCallback, GetFileCallback getFileCallback) { // Handle Callbacks if (viewDataCallback == null || getFileCallback == null) { throw new ArgumentNullException("Callbacks"); } this.m_viewDataCallback = viewDataCallback; this.m_getFileCallback = getFileCallback; // Init ReleaseControl uint response = 0; response = this.m_api.InitiateReleaseControl(this.m_cameraHandle); if (!VerifyReponse(response)) { throw new Exception("InitiateReleaseControl"); } // Init ViewData Timer this.m_timer = new Timer(new TimerCallback((o) => { if (Thread.VolatileRead(ref this.m_accepted) == 1) { return; } Thread.VolatileWrite(ref this.m_accepted, 1); }), null, 0, 100); // Register ViewFinder this.m_prViewFinderCallback = new PRApi.prViewFinderCB(MyViewFinderCB); response = this.m_api.RC_StartViewFinder(this.m_cameraHandle, m_prViewFinderCallback); if (!VerifyReponse(response)) { throw new Exception("RC_StartViewFinder"); } // Register SetEvent this.m_setEventCB = new PRApi.prSetEventCB(MySetEventCB); response = this.m_api.SetEventCallback(this.m_cameraHandle, this.m_setEventCB); if (!VerifyReponse(response)) { throw new Exception("SetEventCallback"); } }
/// <summary> /// Download a file from the server. /// </summary> /// <param name='fileName'> /// File name of the file (full path) /// </param> /// <param name='handler'> /// Callback handler that is invoked for each chunk of the file received /// </param> /// <param name='parameter'> /// User provided parameter that is passed to the callback handler /// </param> public void GetFile(string fileName, GetFileHandler handler, object parameter) { int error; GetFileCallback getFileCallback = new GetFileCallback(handler, parameter); GCHandle handle = GCHandle.Alloc(getFileCallback); IedConnection_getFile(connection, out error, fileName, new InternalIedClientGetFileHandler(iedClientGetFileHandler), GCHandle.ToIntPtr(handle)); if (error != 0) throw new IedConnectionException("Error reading file", error); handle.Free(); }