public partial class MainWindow : Window
{
private FlashControl flash = null;
private Timer timer;
private WindowsFormsHost host = null;
private bool first;
private delegate void myDel(object state);
public MainWindow()
{
InitializeComponent();
first = true;
timer = new Timer(new TimerCallback(Exchange), null, 0, 10);
}
private void Exchange(object state)
{
if (Dispatcher.CheckAccess())
{
grid.Children.Clear();
if (flash != null)
{
flash.ReleaseFlash();
//flash.Dispose();
}
if (host != null) host.Dispose();
host = new WindowsFormsHost();
flash = new FlashControl();
host.Child = flash;
//flash.BeginInit();
if (first)
{
flash.LoadMovie(@"C:\haber.swf");
first = false;
}
else
{
flash.LoadMovie(@"C:\hava.swf");
first = true;
}
flash.SetHeight(350);
flash.SetWidth(525);
//flash.EndInit();
flash.Play();
grid.Children.Add(host);
}
else
{
Dispatcher.BeginInvoke(new myDel(Exchange), state);
}
}
}
Codes flips two flash file in a window rapidly.(Rapidness is just for test when I test in longer period, it also gives error.)
This code gives accessViolationException nondeterministicly in LoadMovie() function.
FlashControl is a user-defined control to wrap flash com objects in wpf application.
Please help it is urgent
ferhat elmas