I've got a form element (a wizard, actually) which is giving me
problems when I try to invoke some of its methods from one of the
methods of a filesystemwatch er. Basically the watcher sits there
waiting to see the file and then it's supposed to go to the next page
(wizard1.Next() ).
I get an InvalidOperatio nException when I do this, though, and as near
as I can tell it's because the watcher creates a new thread and it's
trying to access the form object from a different thread. I don't know
how to fix this, though. Any ideas? I found this helpful page (http://
msdn2.microsoft .com/en-us/library/ms171728.aspx) which seems to be
exactly what I'm asking about, but I just can't figure it out. I've
tried to adapt it to my situation, but it's just over my head... In
particular, the whole backgroundwatch er thing isn't working. For
example, if I do "BackgroundWatc her bgw" and then on the very next
line something like "bgw=new BackgroundWatch er()" it tells me that the
variable bgw is unknown.
Is there any way to force a FileSystemWatch er to use the same thread
it's started in? I don't want or need the user to do anything until
it's done looking anyways. 2 1473
Ian Toltz <it****@gmail.c omwrote:
I've got a form element (a wizard, actually) which is giving me
problems when I try to invoke some of its methods from one of the
methods of a filesystemwatch er. Basically the watcher sits there
waiting to see the file and then it's supposed to go to the next page
(wizard1.Next() ).
I get an InvalidOperatio nException when I do this, though, and as near
as I can tell it's because the watcher creates a new thread and it's
trying to access the form object from a different thread. I don't know
how to fix this, though. Any ideas?
See http://pobox.com/~skeet/csharp/threads/winforms.shtml
Basically, you need to use Control.Invoke/BeginInvoke.
<snip>
Is there any way to force a FileSystemWatch er to use the same thread
it's started in?
You can set the SynchronizingOb ject property to be one of your
controls. That way I believe the calls should end up on the UI thread.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
On Mar 15, 4:30 pm, Jon Skeet [C# MVP] <s...@pobox.com wrote:
Ian Toltz <ito...@gmail.c omwrote:
I've got a form element (a wizard, actually) which is giving me
problems when I try to invoke some of its methods from one of the
methods of a filesystemwatch er. Basically the watcher sits there
waiting to see the file and then it's supposed to go to the next page
(wizard1.Next() ).
I get an InvalidOperatio nException when I do this, though, and as near
as I can tell it's because the watcher creates a new thread and it's
trying to access the form object from a different thread. I don't know
how to fix this, though. Any ideas?
Seehttp://pobox.com/~skeet/csharp/threads/winforms.shtml
Basically, you need to use Control.Invoke/BeginInvoke.
<snip>
Is there any way to force a FileSystemWatch er to use the same thread
it's started in?
You can set the SynchronizingOb ject property to be one of your
controls. That way I believe the calls should end up on the UI thread.
--
Jon Skeet - <s...@pobox.com >http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
That helped a lot and I got it working. Man, that's some weird stuff.
Anyways, thanks a ton! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gianguz |
last post by:
I'd like to discuss about the opportunity to have a global objects
creator that introduces into a general framework
(suited for multithreading) a controlled semantic to manage
globals variables (objects and scalar-types).
In the following example Global is able to create objects of any kind
with and index value attached to. So a Global<0, string> is a unique
string instance object allocated into the system that can be accessed
from any...
|
by: mihai |
last post by:
What does the standard say about those two? Is any assurance that the
use of STL is thread safe?
Have a nice day,
Mihai.
|
by: sarge |
last post by:
I would like to know how to perform simple multithreading.
I had created a simple form to test out if I was multithreading
properly, but got buggy results. Sometime the whole thig would lock
up when I got two threads going at the same time.
What I have is two text boxes (textBox1 and textBox2) and four
buttons(cmdStartThread1, cmdStartThread2, cmdStopThread1,
cmdStopThread2)
|
by: WithPit |
last post by:
I am trying to create an Managed C++ Wrapper around an unmanaged library
which contains C++ code.
Some of the unmanaged methods returns an returntype which is of the abstract
base type (for example unmanagedObject). How can i convert this to the
managed abstract basetype?
Hope somebody can help me
Thanx
|
by: bill salkin |
last post by:
I setup a "Try..." block and attempted to open a non-
existant database. It went to the second "catch" not the
first. What is the proper "catch" clause for this specific
case?
TIA,
Bill
| |
by: Stacey Levine |
last post by:
I have a webservice that I wanted to return an ArrayList..Well the service
compiles and runs when I have the output defined as ArrayList, but the WSDL
defines the output as an Object so I was having a problem in the calling
program. I searched online and found suggestions that I return an Array
instead so I modified my code (below) to return an Array instead of an
ArrayList. Now I get the message when I try to run just my webservice...
|
by: sandy82 |
last post by:
Whats actuallly multithreading is ... and how threading and
multithreading differ .
Can any1 guide how multithreading is used on the Web .. i mean a
practical scenario in which u use multithreading online using C# .
|
by: Chris |
last post by:
I don't know if it's me or .net is just getting more complicated. I am trying
to call a sp and pass a parameter and return the data using VB2005. First I
couldn't find any docs with samples. Second I tryed this
<%@ WebService Language="VB" Class="GetList" %>
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient
|
by: Ray |
last post by:
Hello,
Greetings! I'm looking for a solid C++ multithreading book. Can you
recommend one? I don't think I've seen a multithreading C++ book that
everybody thinks is good (like Effective C++ or Exceptional C++, for
example). Platform-specific (e.g.: Win32, POSIX) is OK, as long as it's
good :)
Thank you,
Ray
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |