ich eine picturebox in meinem Windows-Form haben, die einen Strom von meiner Kamera macht verwendet es einen Worker-Thread wie man sehen kann:System.AccessViolationException: .NET Runtime Error C# Worker-Thread
VideoFileReader reader = new VideoFileReader();
Thread Proceso1;
Proceso1 = new Thread(new ThreadStart(updateui));
public void updateui()
{
try
{
reader.Open(RTSPAddress);
while (true)
{
var previousFrame = pictureRTSP.BackgroundImage;
Bitmap currentFrame = reader.ReadVideoFrame();
pictureRTSP.BackgroundImage = currentFrame;
if (previousFrame != null)
this.Invoke(new MethodInvoker(delegate() {
previousFrame.Dispose();
}));
}
reader.Close();
}
catch(ArgumentException ee)
{
//Text = ee.ToString();
}
}
ich die vorherigen entsorgen Rahmen wegen der Speichernutzung .In meiner Form, ich habe eine Schaltfläche, die pictureRTSP.BackgroundImage
verwenden, um die Platte in der video.But zu erkennen, wenn ich auf die Taste für einige Zeit angeklickt erhalte ich diese Fehlermeldung:
Application: nMCR.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at <Module>.av_read_frame(libffmpeg.AVFormatContext*, libffmpeg.AVPacket*)
at Accord.Video.FFMPEG.VideoFileReader.readVideoFrame(Int32, System.Drawing.Imaging.BitmapData)
at Accord.Video.FFMPEG.VideoFileReader.ReadVideoFrame()
at nMCR.form.MainForm.updateui()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
My Button-Code:
BitmapImage bmImage = null;
if (IsRTSP)
{
//FinalImage = new Bitmap(_snapshotHandler.TakeSnapshot().ToImage());
FinalImage = new Bitmap(pictureRTSP.BackgroundImage);
//Bitmap img = (Bitmap)Image.FromStream(FinalImage);
bmImage = new BitmapImage();
using (MemoryStream memStream2 = new MemoryStream())
{
FinalImage.Save(memStream2, System.Drawing.Imaging.ImageFormat.Png);
memStream2.Position = 0;
bmImage.BeginInit();
bmImage.CacheOption = BitmapCacheOption.OnLoad;
bmImage.UriSource = null;
bmImage.StreamSource = memStream2;
bmImage.EndInit();
}
@Fildor nur mein Fehler .Ich sehen wollen zu wissen, warum ich diesen Fehler bekomme? –
@Fildor könnten Sie mir bitte ich Details geben? –
@Fildor ja genau .i poste das Bild, das zeigt, in welcher Zeile der Fehler passiert –