Wrox Programmer Forums
|
BOOK: Professional VB.NET, 2nd Edition or 2003
This is the forum to discuss the Wrox book Professional VB.NET, 2nd Edition by Fred Barwell, Richard Case, Bill Forgey, Billy Hollis, Tim McCarthy, Jonathan Pinnock, Richard Blair, Jonathan Crossland, Whitney Hankison, Rockford Lhotka, Jan D. Narkiewicz, Rama Ramachandran, Matthew Reynolds, John Roth, Bill Sheldon, Bill Sempf; ISBN: 9780764544002
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional VB.NET, 2nd Edition or 2003 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 November 27th, 2009, 08:39 AM
dmn dmn is offline
Registered User
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Chapter 19 - Pooling Sample Code

Has anyone managed to get the Pooling sample to work? I have created my own application and downloaded the sample code for the book and both fail to run with the same problem.

Quote:
System.InvalidOperationException was unhandled

"Cross-thread operation not valid: Control 'txtStatus' accessed from a thread other than the thread it was created on."
The VS online help seems to be suggesting that we need to invoke the update to the control.

I've coded around the problem by sending the data to the output window.

To prove that I could get data back to the form I modified the WorkerEnd method to pass back some additional data that is stored in private member variables. I then have a timer that loops around and updates the UI every few seconds.
 
Old November 27th, 2009, 10:23 PM
Wrox Author
 
Join Date: Aug 2003
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
Default Old Version

I believe the issue is with the age of the book. In .NET 1.1 and before you could directly access the UI elements on the main thread from a worker thread. However, in .NET 2.0 (I believe) this changed so that you could no longer directly access UI elements from a worker thread. The samples written to do so will not work on current versions of .NET. Take a look at threading from a new version of the book (the code sample) and I expect you'll find that it no longer directly accesses the UI elements from a worker thread.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is the sample code for Chapter 29 reddyjyoshna BOOK: Professional C# 2005 with .NET 3.0 ISBN: 978-0-470-12472-7 0 December 18th, 2008 08:14 AM
Chapter 10 Sample Code jramkawsky BOOK: Professional Java Development with the Spring Framework 0 December 3rd, 2005 08:44 AM
chapter 25 -sample code LouMattera BOOK: Professional C#, 2nd and 3rd Editions 3 February 13th, 2005 06:39 AM
Chapter 16 missing sample code bruceaj VB.NET 2002/2003 Basics 3 June 18th, 2003 08:18 AM





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