Hi!
I'm having my UserControl to show Thumbnails (list of images) using transition control. Image changes one to another every 7 sec. and to achieve this I'm using a Timer. Next is a snipped code:
First image is showed fine, but when timer elapsed is reached, exception is thrown when try to change to another transition effect. Error is:
"The calling thread can not access this object because the owner is another thread". How can I do to achieve this thumbnail???
thanks
I'm having my UserControl to show Thumbnails (list of images) using transition control. Image changes one to another every 7 sec. and to achieve this I'm using a Timer. Next is a snipped code:
public partial class ctlPublicidad : UserControl{Timer m_objTemporizador = new Timer();List<string> m_vaThumbNails = new List<string>();public ctlPublicidad() {this.InitializeComponent();IndiceThumbnailActivo = -1;}// This is execute when UserControl is loadedprivate void UserControl_Loaded(object sender, RoutedEventArgs e) {MostrarSiguienteImagenThumbNail(); m_objTemporizador = new Timer(7000); m_objTemporizador.Elapsed += new ElapsedEventHandler(Temporizador_Elapsed); m_objTemporizador.Start();}void Temporizador_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { MostrarSiguienteImagenThumbNail(); } private void MostrarSiguienteImagenThumbNail() { Random vnNumeroRandom = new Random(); int vnEfecto = vnNumeroRandom.Next(1, 7); switch (vnEfecto) { case 1: TransitionControl.Transition = new MotionBlurredZoomTransition(); TransitionControl.Duration = new TimeSpan(0, 0, 0, 0, 400); break; case 2: TransitionControl.Transition = new FadeTransition(); TransitionControl.Duration = new TimeSpan(0, 0, 0, 0, 750); break; case 3: TransitionControl.Transition = new LinearFadeTransition() { Angle = 0.3, Darker = 0.3, Thickness = 0.2 }; TransitionControl.Duration = new TimeSpan(0, 0, 0, 0, 750); break; case 4: TransitionControl.Transition = new WaveTransition() { Angle = 0.5, Amplitude = 0.15 }; TransitionControl.Duration = new TimeSpan(0, 0, 0, 0, 750); break; case 5: TransitionControl.Transition = new FlipWarpTransition(); TransitionControl.Duration = new TimeSpan(0, 0, 0, 0, 750); break; case 6: TransitionControl.Transition = new SlideAndZoomTransition(); TransitionControl.Duration = new TimeSpan(0, 0, 0, 0, 750); break; case 7: TransitionControl.Transition = new RollTransition(); TransitionControl.Duration = new TimeSpan(0, 0, 0, 0, 750); break; } TransitionControl.Content = new Image() { Source = new BitmapImage(new Uri(m_vaThumbNails[++IndiceThumbnailActivo], UriKind.RelativeOrAbsolute)) }; }}First image is showed fine, but when timer elapsed is reached, exception is thrown when try to change to another transition effect. Error is:
"The calling thread can not access this object because the owner is another thread". How can I do to achieve this thumbnail???
thanks