Lilith,
It might have been easy in C++, but I wonder if you are doing it
correctly. For windows controls (any language which uses the Windows API),
you have to access controls (read or writing) on the thread that created the
control. You are doing work on another thread, so you have to marshal the
call back to the UI thread.
In order to do this, you will need to call the Invoke method on a
control that was created on the UI thread, passing a delegate which will
perform the operation you want (in this case, reading the value, or writing
the value).
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"Lilith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This was easy in C++ (well, relatively.) Now I'm in the C#
> environment and everything I try doesn't work.
>
> I'm running a thread in which I have two accesses I need to components
> on a form. In one instance it's to simply check the text of a button
> as an indicator of whether I've got a request to end the thread. This
> is a read-only situation so I don't have to worry about
> synchronization. The other is a need to write status information to
> either a text box or a label. The thread is the only thing that
> writes to this field so, again, no conflict.
>
> I've tried with a static method within the form itself and with a
> non-static method contained in a class object. I've tried accessors,
> with which I'm not fully comfortable yet and might not know how or
> where to declare it (I get an "already contains definition..." error.
> I've tried fully qualified paths to the text but get an error message
> that I need an object reference for the non-static field.
>
> Please advise.
>
> --
> Lilith