Dispose() public method

Dispose the object.
Frees unmanaged resources used by the object. The object becomes unusable after that.
public Dispose ( ) : void
return void
Example #1
0
        public void StartRecording()
        {
            if (!RecordVideo)
            {
                DateTime date = DateTime.Now;
                string filePath = _folderPath + String.Format("\\{0}-{1}-{2} {3}-{4}-{5}.avi",
                    date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);
                int width = 640;
                int height = 480;
                int frameRate = 15;
                
                try
                {
                    if (!Directory.Exists(_folderPath))
                        Directory.CreateDirectory(_folderPath);

                    _aviWriter = new AVIWriter("wmv3");
                    _aviWriter.FrameRate = frameRate;
                    _aviWriter.Open(filePath, width, height);

                    SendMessage("recording");
                    AddClient(this);
                    RaiseRecordEvent();
                    RecordVideo = true;
                }
                catch
                {
                    if (_aviWriter != null)
                    {
                        _aviWriter.Dispose();
                        _aviWriter = null;
                    }
                }
            }
        }
Example #2
0
        public void StartRecording()
        {
            if (!RecordVideo)
            {
                DateTime date = DateTime.Now;
                string filePath = folderPath + String.Format("\\{0}-{1}-{2} {3}-{4}-{5}.avi",
                    date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);
                int width = 640;
                int height = 480;
                int frameRate = 15;
                
                try
                {
                    if (!Directory.Exists(folderPath))
                        Directory.CreateDirectory(folderPath);

                    SendMessage("recording");
                    // create AVI writer
                    aviWriter = new AVIWriter("wmv3");
                    aviWriter.FrameRate = frameRate;
                    // open AVI file
                    aviWriter.Open(filePath, width, height);
                    // register as a client to receive frame
                    AddClient(Record);
                    MotionAlarmed(this, "recording");

                    RecordVideo = true;
                }
                catch (ApplicationException)
                {
                    if (aviWriter != null)
                    {
                        aviWriter.Dispose();
                        aviWriter = null;
                    }
                }
            }
        }