public void recordTime(object source, System.Timers.ElapsedEventArgs e) { if (!m_bPauseLocalPlay) { float pos = XMSDK.H264_DVR_GetPlayPos(m_nLocalplayHandle); if (InvokeRequired) { BeginInvoke((MethodInvoker)(() => trackBarLocalPlayPos.Value = Convert.ToInt32(pos * 1000))); } else { trackBarLocalPlayPos.Value = Convert.ToInt32(pos * 1000); } } if (!m_bPauseNetPlay) { float pos = XMSDK.H264_DVR_GetPlayPos(m_nNetPlayHandle); if (InvokeRequired) { BeginInvoke((MethodInvoker)(() => trackBarNetPlayPos.Value = Convert.ToInt32(pos * 1000))); } else { trackBarNetPlayPos.Value = Convert.ToInt32(pos * 1000); } } if (m_DownLoadFileHandle != 0) { int nPos = XMSDK.H264_DVR_GetDownloadPos(m_DownLoadFileHandle); if (nPos < 0) //fail { XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle); progressBarDownloadPos.Value = 0; m_DownLoadFileHandle = 0; btnDownload.Text = "Download"; MessageBox.Show("Get download process fail !"); timerDownload.Stop(); } if (nPos == 100) //download end { XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle); m_DownLoadFileHandle = 0; timerDownload.Stop(); if (InvokeRequired) { BeginInvoke((MethodInvoker)(() => progressBarDownloadPos.Value = 0)); } else { progressBarDownloadPos.Value = 0; } btnDownload.Text = "Download"; MessageBox.Show("Download Finished"); return; } if (nPos > 100) //abnormal { XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle); m_DownLoadFileHandle = 0; if (InvokeRequired) { BeginInvoke((MethodInvoker)(() => progressBarDownloadPos.Value = 0)); } else { progressBarDownloadPos.Value = 0; } btnDownload.Text = "Download"; MessageBox.Show("Download Error"); } else { if (InvokeRequired) { BeginInvoke((MethodInvoker)(() => progressBarDownloadPos.Value = nPos)); } else { progressBarDownloadPos.Value = nPos; } } } }