使用以下代码,我们得到错误“对象当前正在其他地方使用”
private void CaptureDone(System.Drawing.Bitmap e)
{
try
{
this.pictureBox.Image = e;
if (isSending)
ThreadPool.QueueUserWorkItem(new WaitCallback(SendVideoBuffer), pictureBox.Image);
}
catch (Exception) { }
}
void SendVideoBuffer(object bufferIn)
{
TcpClient tcp = new TcpClient(ConfigurationSettings.AppSettings[0].ToString(), 6000);
NetworkStream ns = tcp.GetStream();
if (ns != null)
{
System.Drawing.Image buffer = (System.Drawing.Image)bufferIn;
buffer.Save(ns, System.Drawing.Imaging.ImageFormat.Jpeg);// error comes here
ns.Close();
tcp.Close();
}
}
请提出建议。