库文件
System.Threading
项目
录音系统V3.0(C/S)
代码段
private void FrmMain_Load(object sender, EventArgs e)
{
ThreadClass tcTbmm = new ThreadClass(null ,null,new ThreadCallback(TbMMControl));//播放进度条控制线程
m_tbMM = new Thread(new ThreadStart(tcTbmm.ThreadProc));//创建线程
m_tbMM.IsBackground = true;//系统自动释放。
m_tbMM.Start();
}
private void TbMMControl(object wParam, object lParam)
{
while (!Program.g_bAppExit && !this.IsDisposed)
{
SettbMM();
Thread.Sleep(10);
}
}
//在此例中可以不看,只是一个软件中的功能实现
private void SettbMM()
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(SettbMM), new object[0] { });
return;
}
if (Convert.ToInt32(this.MPlayer.playState) == 3)//this.MPlayer.currentPlaylist.count > 0 && 播放状态,1=停止,2=暂停,3=播放,6=正在缓冲,9=正在连接,10=准备就绪
{
this.tbMM.Maximum = Convert.ToInt32(this.MPlayer.currentMedia.duration * 100);
if (this.MPlayer.currentMedia.duration * 100 == 0 || this.tbMM.Value < this.tbMM.Maximum)
{
this.tbMM.Value += 1;
}
if (this.tbMM.Value == this.tbMM.Maximum/2)
{
this.MPlayer.Ctlcontrols.currentPosition = Convert.ToDouble(this.tbMM.Value / 100);
}
int lbtext = Convert.ToInt32((tbMM.Value) / 100);
string strlbtext = (lbtext / 3600).ToString("00") + ":" + ((lbtext % 3600) / 60).ToString("00") + ":" + ((lbtext % 3600) % 60).ToString("00");
lbCurtime.Text = strlbtext.ToString();
}
else if (Convert.ToInt32(this.MPlayer.playState) == 1)
{
this.tbMM.Value = 0;
this.tbMM.Enabled = false;
lbCurtime.Text = "00:00:00";
tspbLoadFile.Visible = false;
}
}