This happens with the ActiveX control or calling native code in C#.
To test just drop the Ax control on a form and loop start/stop calls. Looks like 3-5 handles per loop.
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace VlcActiveXTest
{
public partial class Form1 : Form
{
long iteration = 0;
public Form1()
{
InitializeComponent();
}
bool first = true;
protected void RestartVideo()
{
textBoxOutput.Text = "Stream Start Iteration #" + iteration + " Done";
try
{
Interlocked.Increment(ref iteration);
if (!first)
{
this.axVLCPlugin21.playlist.stop();
}
else
{
first = false;
this.axVLCPlugin21.playlist.clear();
this.axVLCPlugin21.playlist.add(textBoxProxyUrl.Text, "test", ":file-caching=0");
}
this.axVLCPlugin21.playlist.play();
}
catch
{
textBoxOutput.Text += Environment.NewLine + Environment.NewLine + "Error";
buttonGo_Click(null, null);
}
finally
{
}
}
bool flipOn = true;
private void buttonGo_Click(object sender, EventArgs e)
{
if (flipOn)
{
RestartVideo();
timer1.Start();
flipOn = false;
}
else
{
flipOn = true;
first = true;
iteration = 0;
timer1.Stop();
this.axVLCPlugin21.playlist.stop();
}
}
private void timer1_Tick_1(object sender, EventArgs e)
{
RestartVideo();
}
}
}