468,772 Members | 1,888 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,772 developers. It's quick & easy.

Want to call DoEvents from library project

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.
Nov 16 '05 #1
3 4386
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.

Nov 16 '05 #2
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.


Nov 16 '05 #3
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.


Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Srinivas Kollipara | last post: by
1 post views Thread by Abdalla Fawaz El-Hawary | last post: by
3 posts views Thread by Edward | last post: by
1 post views Thread by RSH | last post: by
12 posts views Thread by Justin | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.