dotNETDavid,
In a library project, you have to add a reference to
System.Windows.Forms, and then add the using declaration for the namespace
System.Windows.Forms at the top of the file you want to use it in.
You can't be using threading if you are waiting on the UI thread.
Rather, you should spawn those functions out to another thread and have that
thread wait. If you run this in an environment that does not have access to
the UI, then the call to DoEvents might fail, and it would defeat the
purpose of having it in a separate library.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"dotNETDavid" <do*********@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
Nicholas:
Calling System.Windows.Forms.Application.DoEvents(); gives the error:
<path>\Comm.cs(354): The type or namespace name 'Windows' does not exist
in
the class or namespace 'System' (are you missing an assembly reference?)
when I use it in a library project.
I'm using a serial port dll that does use threading. While waiting for
input
from the port I'm in a loop where I'd like to call DoEvents to allow other
applications to have more timeslices.
Thanks for the help.
"Nicholas Paldino [.NET/C# MVP]" wrote:
dotNETDavid,
Why can't you call DoEvents? It is a public static method on the
Application object. You should have no problem calling it.
However, whether or not you SHOULD call it, that is a different
story.
If you have a long running operation, then you should really spawn it off
to
another thread, and eliminate the need to have DoEvents called. There
really is little reason to call DoEvents, ever. It's a hack for those
that
don't use threads to perform long operations.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"dotNETDavid" <do*********@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com... > We've broken our app into various assemblies. The WinForm assembly
> provides
> the user interface, other assemblies provide various I/O services. I'd
> like
> to be able to call System.Windows.Forms.Application.DoEvents from
> within a
> dll, but it isn't allowed. I don't want to link the dll to our WinForm
> exe
> which can call DoEvents.
>
> Is there some way to call DoEvents from within a dll?
>
> Thanks.