Control.Invoke must be used to interact with controls created on a separate thread

by Mark Deraeve 20. July 2008 17:35

I've migrated a windows CE 4.20 application to windows CE 5.0. This is not without effort. Some things have to be rewritten. I will explain the steps I took in order to get rid of the error: "Control.Invoke must be used to interact with controls created on a separate thread.".

The application worked fine in windows CE 4.2. What is does is when a transponder is scanned it send an event to the forms. In this event I wanted to set properties of my controls. The code looked like this:

public void HandleISOTagScannedEvent(string isoTag)
            {
                  bool Found = false;
 
                  try
                  {
                        int Index = 0;
                        IEnumerator Enumer = cboThings.Items.GetEnumerator();
                        while(Enumer.MoveNext())
                        {
                             Thing ThisThing = new Thing(((DataRowView)Enumer.Current).Row);
                             if (ThisThing._rfId == isoTag)
                             {
                                   cboThings.SelectedIndex = Index;
                                   this.SetThing(ThisThing._guid);
                                   Found=true;
                                   break;
                             }
                             Index++;
                        }
 
                        if (!Found)
                        {     
                             FormsManager.ShowMessage("Thing {0} does not exist!", isoTag);
                        }
                  }
                  catch (Exception ex)
                  {
                        TraceExceptionForm.Display("TubeSetupForm", "HandleISOTagScannedEvent", ex);
                  }
            }
 

When I migrated the application to .Net 2.0 and CE 5 and deployed it to the mobile device, everything seem to work. Then I started testing and when I scanned a transponder, the error first occurred. Control.Invoke must be used to interact with controls created on a separate thread. I started to Google around and found the solution on this website by David Kline: http://blogs.msdn.com/davidklinems/archive/2006/03/09/548235.aspx. I had to make a delegate on the form and use this to change the properties. Now the code looks like this:

 

private delegate void UpdateStatusDelegate(int index, Guid guid);
 
private void ChangeThing(int index, Guid guid)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (this.InvokeRequired)
            {
                // we were called on a worker thread
                // marshal the call to the user interface thread
                this.Invoke(new UpdateStatusDelegate(ChangeThing),
                            new object[] { index,guid });
                return;
            }
            
            cboThings.SelectedIndex = index;
            this.SetThing(guid);
            Cursor.Current = Cursors.Default;
        } 
 
 
            public void HandleISOTagScannedEvent(string isoTag)
            {
                  bool Found = false;
 
                  try
                  {
                        int Index = 0;
                        IEnumerator Enumer = cboThings.Items.GetEnumerator();
                        while(Enumer.MoveNext())
                        {
                             Thing ThisThing = new Thing(((DataRowView)Enumer.Current).Row);
                             if (ThisThing._rfId == isoTag)
                             {
                        ChangeThing(Index, ThisThing._guid);
                                   Found=true;
                                   break;
                             }
                             Index++;
                        }
 
                        if (!Found)
                        {     
                             FormsManager.ShowMessage("Thing {0} does not exist!", isoTag);
                        }
                  }
                  catch (Exception ex)
                  {
                        TraceExceptionForm.Display("SetupForm", "HandleISOTagScannedEvent", ex);
                  }
            }
 

Problem solved. I hope this can help people with simular problems.

 Maybe someone can explain why on wondows CE 4.2 this was not giving any problem and in windows CE 5.0 it is? Or could it have something todo with the compact framework?  


Tags:

Comments (33) -

Olga
Olga
2/19/2009 4:26:40 PM #

You help me wery mach.
Thanks!

lengyelg
lengyelg
5/22/2009 3:15:33 AM #

Thx Smile))

Mark
Mark
6/3/2009 2:59:26 PM #

Your welcome...

grants for college
grants for college
12/31/2010 3:47:15 PM #

Very nice post and right to the point. I don't know if this is in fact the best place to ask but do you people have any ideea where to hire some professional writers? Thx Smile

tv online
tv online
12/31/2010 8:36:29 PM #

I wanna recomand you a nice website to watch your favorites tv channels online: http://www.tv-online-live.com

free online porn
free online porn
1/1/2011 1:37:30 AM #

I will post a link to this page on my blog.

Marketing Tools
Marketing Tools
1/1/2011 4:05:41 AM #

Managing your Marketing Campaign.It automatically submits it to Video Sites, Photo Sites, Blogs, Micro Blogs, Bookmarking Sites, RSS Feeds,Press Release Sites, and dozens more.<a href="singledad.de/businesspromoting">Marketing Tools</a>

tera patrick freeones
tera patrick freeones
1/1/2011 3:50:48 PM #

I have studied a few of the articles on your blog, and I genuinely like your style of writing. I added it to my bookmarks blog site directory and will be coming back in the near future.

Nida Joerger
Nida Joerger
1/1/2011 11:09:59 PM #

I'd like to post a snippet of this article on my web site I hope the author will allow me! Thanks

online casino
online casino
1/2/2011 11:15:58 AM #

Would you like to post a guest post on my blog?

Richard Danz
Richard Danz
1/2/2011 10:52:33 PM #

I'd like to post a snippet of this article on my new homepage I hope you will let me! Thanks

tori black rocco
tori black rocco
1/3/2011 1:01:41 AM #

Your blog is outrageous! I mean, Ive never been so entertained by anything in my life! Your vids are perfect for this. I mean, how did you manage to find something that matches your style of writing so well? Im really happy I started reading this today. Youve got a follower in me for sure!

Bryan Sulecki
Bryan Sulecki
1/3/2011 8:03:22 AM #

Great post and very well written. Thanks

Denny Hilderbrand
Denny Hilderbrand
1/3/2011 11:00:04 AM #

Great post and very well written. Thanks

Tamie Gunnells
Tamie Gunnells
1/3/2011 6:42:37 PM #

cheers into d' whole new year keep in submitting awesome content

Fb Objective Review
Fb Objective Review United States
11/24/2013 11:55:52 PM #

Hello, i feel that i noticed you visited my web site so i got here to go back the choose?.I am trying to in finding issues to enhance my website!I suppose its good enough to use a few of your ideas!!

austin personal injury
austin personal injury United States
12/24/2013 1:35:53 PM #

Should you are using WordPress, to about arrive spam difficulty just set up plug-in contact Akismet.

Denver SEO
Denver SEO United States
12/28/2013 6:18:08 PM #

Really Nice Blog! If you are looking for Denver SEO, make certain to check out www.ethicalseoconsulting.com

Denver SEO
Denver SEO United States
12/28/2013 6:42:07 PM #

Really Nice Blog! If you are looking for Denver SEO, make certain to check out www.ethicalseoconsulting.com

Denver SEO
Denver SEO United States
12/28/2013 6:42:07 PM #

Really Nice Blog! If you are looking for Denver SEO, make certain to check out www.ethicalseoconsulting.com

Denver SEO
Denver SEO United States
12/28/2013 6:42:07 PM #

Denver SEO firm, www.ethicalseoconsulting.com might be exactly what you are looking for!

Denver SEO
Denver SEO United States
12/28/2013 6:42:07 PM #

Really Nice Blog! If you are looking for Denver SEO, make certain to check out www.ethicalseoconsulting.com

Denver SEO
Denver SEO United States
12/31/2013 4:46:50 PM #

Denver SEO firm, www.ethicalseoconsulting.com might be exactly what you are looking for!

Denver SEO
Denver SEO United States
12/31/2013 5:15:16 PM #

Really Nice Blog! If you are looking for Denver SEO, make certain to check out www.ethicalseoconsulting.com

Denver SEO
Denver SEO United States
12/31/2013 5:15:17 PM #

Really Nice Blog! If you are looking for Denver SEO, make certain to check out www.ethicalseoconsulting.com

injury attorney austin
injury attorney austin United States
1/1/2014 9:39:11 AM #

Manny This really solved my difficulty, thank you! I was quite happy to discover this website.I wished to appreciate it for this outstanding read through!! I undoubtedly enjoying every single minimal little bit of it and i have you ever saved like a most loved to check out new stuff you blog site write-up. Respectfully, Suzann. Very good occupation! what a terrific submit! Thank you greatly. An insightful web site publish there mate . Cheers for that write-up ! Seriously savored this weblog post. Thanks and retain them coming. This website entry has some precious information I'll be capable of implement to my instances. Thanks for your article. I have been exploring many of your content and that i should say rather intelligent things. I will absolutely bookmark your internet site to share it with other bloggers later. Just one of my favorites! Your website includes a ton of exceptional written content that is congruent to my own. Many thanks for submitting. Many thanks on your valuable web site! Thanks, you website has some terrific info. This put up is a really very good post. Actually enjoyed this web site publish. Thanks and maintain them coming. This blog entry has some valuable facts I will be capable of implement to my situations. Thanks for the write-up. I've been researching a lot of your content articles and that i should say fairly intelligent things. I will absolutely bookmark your internet site to share it with other bloggers later. One of my favorites! Your site contains a good deal of remarkable content that's congruent to my very own. Many thanks for submitting. Hola! I have been adhering to your weblog for a very long time now and at last obtained the bravery to go ahead and provide you a shout out from Austin Tx! Just wished to state keep up the nice perform! I am regularly browsing on the web for posts that will help me by putting up them on my twitter account. I will be dropping a link in your post every number of times. Thanks! I also believe that quite a bit of individuals develop into susceptible to believing that there worthless or almost nothing for the environment as they get turned down. I feel the best detail to try and do is move on and devoted your emotions to a thing else value worrying or considering about this is jam-packed with facts and i'm glad you are truly composing about this challenge, demonstrating us all absolutely unique sides to it. you're a terrific blogger. Make sure you retain it up. I cant wait to search whats upcomingI'm now not guaranteed the area you're receiving your information, but excellent topic. I would like to invest some time understanding much more or being familiar with far more. Many thanks for your impressive data I used to be on the lookout for this details for my investigate paper. Hy, thereReally pleasant web page,thank you very much in your time in writing the posts. That may be a really great idea especially to those people new towards the blogosphere. Simple but extremely specific info... Appreciate your sharing this 1. Essential examine posting! Excellent write-up! Hunting ahead to studying additional. It really is actually a nice and valuable piece of data. I am happy which you just shared this useful info with us. You should maintain us up to date similar to this. Thanks for sharing. Quite nice post. I just stumbled upon your weblog and wanted to say that i have truly savored browsing your weblog posts. Immediately after all I?ll be subscribing with your rss feed and that i am hoping you compose once again extremely quickly! A formidable share! I've just forwarded this onto a coworker who may have been conducting just a little analysis on this. And he really acquired me evening meal because I found it for him... lol. So let me reword this.... Thanks with the meal!! But yeah, many thanks for paying a while to debate this concern right here with your world-wide-web website. Quite fantastic article. I just stumbled upon your weblog and preferred to mention that I have really liked searching your weblog posts. In any scenario I'll be subscribing for your feed and that i am hoping you write once a lot more really soon! Terrific put up sustain the great perform, many thanks to the data, I'll go your post on to my buddies. incredible post, thank you for the good posting. Many thanks for your fantastic post.. Extremely useful article. I have located your blog via Google and i am truly joyful about the data you supply in the posts. Btw your web sites structure is actually damaged around the Chrome browser. Can be neat in case you could take care of that. Anyhow keep up the good work! I enjoy you sharing this website article. Genuinely thank you! Definitely Wonderful. Superb items from you, guy. I have understand your stuff earlier to therefore you are merely too fantastic. I in fact like what you have acquired in this article, definitely like what you are stating along with the way during which you say it. You make it entertaining so you nevertheless care for to maintain it sensible. I can not wait to examine much more from you. This can be basically a huge world-wide-web internet site. Its such as you read my intellect! You appear to find out lots relating to this, like you wrote the ebook in it or a thing. I do think that you just could do that has a number of pics to travel the message household a bit, but in addition to that, this is often superb site. An incredible examine. I'll surely be back. Hello, I just examine texts in your blog site and that i took an interest during the topic. I really like your site and that i am thinking no matter if I could use your terms in my work? Would it be doable? If indeed, please create to me.Thank you. I used to be checking frequently this blog site and i am amazed! Really helpful data specifically the last portion I take care of these details much. I had been looking for this selected info for years. Thanks and better of luck. Hello there there I am so thrilled I discovered your weblog, I actually identified you accidentally, though I had been searching on Bing for something else, Even so I am right here now and would identical to to say thank you to get a wonderful publish and also a all spherical attention-grabbing weblog (I also like the theme/design), I haven't got time and energy to read it all on the second but I have book-marked it and in addition provided your RSS feeds, so when i have time I'll be again to examine an excellent deal far more, You should do sustain the superb career. thanks for guidance I will use every one of the 5 ideas tunes,transfer,laugh,enjoy and meditate for dwelling I have browse a couple of great things below. Unquestionably really worth bookmarking for revisiting. I wonder exactly how much effort you set to create this kind of excellent informative net website. Certainly interesting thanks, It looks like your latest subscribers might want more evaluations of the character keep up the nice material. Outstandingly useful many thanks, It can be my viewpoint your latest followers could very properly desire a ton additional content material related to this keep on the wonderful tricky function. Appreciated looking at this, great things, thanks . Intriguing post, Albert, and really genuine inside your past statement. How quickly will you update your blog site? I am keen on studying some additional information on this challenge. Yes you'll be able to subscribe by way of RSS feed symbol surface in top rated ideal hand corner from the header. Some excellent feelings below. Have you been persuaded it's the proper approach to appear at it despite the fact that? My pretty own unique information is that absolutely everyone must pretty a superb offer are living and let remain given that what one individual unique human being thinks just yet one more male simply just does not. Human beings are about to do what they desire to carry out. Within your close, they consistently do. Just one from the most we can pray for will be to highlight a couple of items the subsequent and there that with any luck ,, permits them to build only a very little much better informed decision. Or else, excellent publish. You're certainly producing me consider! hi there, seriously delighted to own observed this page. Its an incredible useful resource and stretches your thinking. Really inspirational I found your blog site on Google , that is a wonderful web site , i'll come back. I've genuinely liked your blog...obtained some seriously good stuff.. i'll try to promote it in brazilian social media network TKS Madeira Biossintetica Advantageously, the write-up is the truth is the freshest subject matter on curing acne normally. I concur with all your conclusions and can thirstily glance ahead to the forthcoming updates. Just saying many thanks will not just be ample, with the phenomenal clarity in your creating. I'll immediately get your rss feed to remain abreast of any updates. I agree together with the over submit. Individually I cannot realize why you would not would like to make an hard work with this regard anyway. Only the other working day, at get the job done we experienced just precisely the same discussion and arrived into a related decision Was wondering precisely precisely the same, cool website, thanks. Hi, this is certainly my initially time i take a look at here. I discovered a lot of appealing as part of your weblog particularly on how to determine the subject. keep up the great perform. Hey, good blog, but I don't understand how so as to add your web site in my rss reader. Could you Support me make sure you? Have discovered your website. My pal pointed out it to me prior to, yet never received close to to checking it out until eventually now. I must convey, I'm floored. I really appreciated looking at by your posts and will completely be again to acquire additional. thanks to the article. I'm very pleased to read through this article. . . . . You will discover unquestionably a great deal of facts like that to take into account. That?s an incredible level to carry up. I offer the thoughts higher than as normal inspiration but evidently you will find queries similar to the one particular you convey up the place a very powerful factor might be Amazing article as envisioned. This is a actually superior read through for me. Need to admit that you are just one from the coolest bloggers I ever saw. Thanks for submitting this insightful short article. Hi I found your site by mistake when i was hunting yahoo for this acne breakouts challenge, I must say your web site is really helpful I also enjoy the look, its wonderful!. I don't have time on the moment to totally study your website but I have bookmarked it and likewise add your RSS feeds. I'll be back within a day or two. thanks for any excellent internet site. I'm actually thankful for the writer of the post for creating this wonderful and instructive report reside in this article for us. We actually take pleasure in ur exertion. Sustain the great do the job. . . . I am just building a website similar to this. If you enable, I would prefer to use several of your material. And with entire refernce not surprisingly. Many thanks upfront. Obtaining internet websites with just as much data as this one particular is often a satisfaction I wll ensure to come back back again and check out once again actual soon, keep up the good get the job done. Nicely, this is certainly my very first visit towards your website! We're a gaggle of volunteers and starting a fresh initiative within a neighborhood from the same niche. Your web site presented us useful facts to work on. You've completed a marvellous career! Took me time to study all of the reviews, but I really liked the article. It proved to generally be Very beneficial to me and that i am positive to all the commenters here! It is usually wonderful whenever you can not only be told, but in addition entertained! Very good submit. I just stumbled on your site and wished to state which i have definitely liked reading through your web site posts. Any way I will be subscribing towards your feed and that i hope you submit yet again shortly. Wonderful Web site! I have a similar web site, and acquire lots of spam. Do you deal with these types of challenges? Could you you should advocate some steps I just take to battle spam. Thanks. Took me awhile to read through the many responses, but I really relished the article. It proved to be really valuable to me and that i am guaranteed to each of the commenters here! It is usually awesome after you cannot only be informed, but in addition engaged! I am certain you had pleasurable scripting this short article. I much like the structure of your web site and Im intending to do the exact same for mine. Do you have any tips? Be sure to PM ME. Significantly, the post is actually the sweetest subject on curing acne naturally. I concur with all your conclusions and will thirstily seem forward for your long term updates. Just indicating many thanks will likely not just be ample, with the large lucidity in your creating. I'll straight away grab your rss feed to stay abreast of any updates. I am probably not certain if best procedures have emerged all over points like that, but I'm positive that your great career is evidently recognized. I was questioning when you offer any membership for your RSS feeds as I would be really fascinated. I have really enjoyed reading your article content. You obviously know very well what that you are talking about! Your site is very easy to navigate far too, I have bookmarked it in my favourites. . . . . I such as structure of the web site and Im gonna do the identical for mine. Does one have any guidelines? Be sure to PM ME. Good subject matter for producing a powerful dissertation. . . . . . You truly ensure it is appear to be really easy with the presentation but I obtain this topic to get actually something which I believe I might under no circumstances fully grasp. It seems as well sophisticated and really wide for me. I'm seeking forward for your following put up. Constantly on the lookout for guidelines to spice up my everyday living.-Online Relationship Tips Good Blog! I have an identical website, and get a whole lot of spam. Do you deal with such difficulties? Is it possible to please suggest some ways I just take to overcome spam. Thanks. Hello Justine,

austin texas persaonl injury attorneys
austin texas persaonl injury attorneys United States
1/4/2014 7:16:04 AM #

Feel free to pay a visit to my web-site; viagra on line - wiki.icpc-bolivia.edu.bo/index.php?title=Usuario:BartSeifert Many thanks in support of a different useful position. Wherever besides may I get that kindly of information written in this type of perfect way? I have a project that I'm just straight away functioning by, and i are about the look made known on behalf of these types of details. Yay google is my king assisted me to uncover this outstanding internet site ! . I'll immediately grasp your rss as I am able to not obtain your e-mail subscription link or newsletter service. Do you've got any? Be sure to allow for me have an understanding of in order which i could subscribe. Many thanks.

car accident attorney Austin
car accident attorney Austin United States
1/9/2014 10:08:33 AM #

My homepage: unstitched salwar kameez clothing garments - allinchrist.net/.../index.php extremely nice put up, i basically really like this internet site, retain on it Remarkable items listed here. I am quite glad to search your write-up. Many thanks so much and i am wanting forward to touch you. Will you remember to drop me a mail?

car accident attorney Austin
car accident attorney Austin United States
1/23/2014 5:17:13 PM #

Right here is my online page - refinancing with bad credit ( topstorageauctions.com - topstorageauctions.com/index.php ) Hi there! I merely want to supply you a huge thumbs up for the terrific details you have got listed here on this submit. I will be returning on your internet site for additional soon.

car accident attorney Austin
car accident attorney Austin United States
1/26/2014 1:04:46 PM #

existing listed here at this weblog, many thanks admin of the web page. I merely choose to mention I'm all new to running a blog and honestly favored your website web-site. Very likely I'm planning to bookmark your site . You surely come with extraordinary posts. Regards for sharing your website. I just would like to tell you that i am just really new to blogs and genuinely appreciated your website web page. Very likely I'm setting up to bookmark your website . You definitely have terrific content and reviews. Value it for revealing your web-site. Admiring the commitment you set into your sife and detailed

personal injury lawyers Austin
personal injury lawyers Austin United States
2/24/2014 11:11:18 PM #

a little bit originality! Many thanks for sharing your facts. I actually take pleasure in your efforts and that i will be waiting on your further article thanks the moment all over again. Hey there and thanks for this beneficial details. I have doing compensated surveys for a lot of years and i can tell you one particular matter, you could make a dwelling from them. Here's a free web-site that teach you how it works so you too could make money just by having on-line surveys. Naturally it operates greater in the event you stay in the United-Satates or in Canada. With the rest of the countries I are not able to tell but anyway just possess a glance by clicking on the Make money by doing free on the net surveys connection. Have a pleasant day and have enjoyable. Hi to each individual body, it's my to start with pay a quick take a look at of this

million hits secret
million hits secret United States
8/9/2014 6:28:13 AM #

Just about all I can comment on is, I'm not sure what to really say! Except certainly, for the superb tips that are shared with this blog. I will think of a zillion fun tips on how to read the reports on this site. I do think I will ultimately take a step utilizing your tips on areas I could never have been able to address alone. You had been so considerate to allow me to be one of those to benefit from your beneficial information. Please recognize how great I am thankful.

best wordpress plugins email subscription
best wordpress plugins email subscription United States
8/15/2014 10:18:04 PM #

Hello There. I discovered your blog the usage of msn. That is a really well written article. I will make sure to bookmark it and come back to learn extra of your useful info. Thanks for the post. I'll definitely comeback.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About the author

I started as a VB6 developer, programming all kinds of applications. I also got involved in the development of a e-market in ASP.

When .Net was introduced, I had the privilege to start in a team of professionals and develop a framework. I learned a lot and started to work as a c#.Net consultant from then on.

After 2 years I also got the chance to work for several months with Sharepoint. Sharepoint kept chasing me all the years after and when the product got more and more mature I started to love it. Now Sharepoint is a somewhat daily occupation for me. I implemented a large quality document management system at PMRL being the only developper/technical analyst. Working close togehter with the QA department we succeeded in making and improving a very good Quality document management system. Its used up until this day.

I worked for 6 years as a .Net consultant for 2 of the largest consultancy companies in Belgium. I mainly worked as a Sharepoint engineer, but also .Net expert and several ASP.Net and Windows applications. One of my last projects with the consultancy was creating a custom LIMS system. This was a succes and the customer asked me to stay and help to expand and maintain this LIMS. I had great years in this company. There was a focus on innovation and a lot of opportunities for improving and developping new IS systems. Apart from several small projects I further more improved the custom LIMS system, created a SOP library based on Sharepoint and a web based Skill matrix system to handle the skills of the employees in the company. 

Then I was involved in transferring the LIMS to a new lab in Singapore. This was done in a short time frame. The deployment was again a success and it passed the GLP inspection tests. I learned a lot from the Quality engineers about validation of computerized systems.

At my current job I have a wide range of challenges. Mainly I'm still working with .Net (VB.net and C#.Net). But outside of the Microsoft world I also do some ABAB programming in our SAP system. Like developing Adobe Forms and the program behind it. Or making small changes to customized code.

Latest I started to follow a course from Stanford Univercity on Objective C programming for IPAD and IPHONE.I just finished the first app for IPad and it appears to be a great succes. People in the factory are working with IPad to take pictures and upload them to orders. Already more and more projects are coming my way. The iOS apps are supported by a home made .Net architecture that exposes WCF services. Its working great. My second app is almost ready for deployment in factories. Now I started an App for the management team so they can manage projects on their IPAD and IPHONE.

My linkedIn!

Month List

Tag cloud

Locations of visitors to this page