Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 4.0 aka C# 2010 > C# 4.0 aka C# 2010 General Discussion
|
C# 4.0 aka C# 2010 General Discussion Discussions about the C# 4.0, C# 4, Visual C# 2010 language and tool not related to any specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 4.0 aka C# 2010 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 6th, 2011, 11:50 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Christian

Well I have tried that too and it ended in Invalid cross thread exception error...

the code changes:
public class ThumbnailsViewModel : INotifyPropertyChanged { BitmapImage bmImage1;
................
............................
}
Code:
 private BitmapImage base64StringToImage(string base64String)
        {
            bmImage1 = new BitmapImage();
            Byte[] imageBytes = Convert.FromBase64String(base64String);
            using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
            {
                ms.Write(imageBytes, 0, imageBytes.Length);
                using (AutoResetEvent are = new AutoResetEvent(false))
                {
                  
                    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            bmImage1.SetSource(ms);
                            are.Set();
                        });
                    are.WaitOne();
                    //ms.Close();
                    //ms.Dispose();
               }
             
            }
            //Thread.Sleep(1000);
            //BitMapImageCheck(bmImage1);
            return bmImage1;
        }
bmImage1 = new BitmapImage(); ---> this is where the error is hit, what to do?
 
Old August 6th, 2011, 01:15 PM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Christian

Thanks a lot! Issue is solved! :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross-Thread Error ricespn Visual Basic 2008 Essentials 0 July 16th, 2009 02:33 PM
cross thread exception YoungLuke C# 1 March 23rd, 2008 06:46 PM
cross thread exception with windows live API YoungLuke C# 2008 aka C# 3.0 1 March 23rd, 2008 01:43 PM
cross thread Error angelboy C# 2005 1 July 28th, 2007 04:35 AM
Cross-thread operation not valid Richw71 C# 0 December 13th, 2006 09:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.