473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 4730
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Srinivas Kollipara | last post by:
Hey guys, In my project one place I am using Application.DoEvents() and waiting for 5 minutes to finish my required task in that block. My project need to run for almost 60 hours continuously to...
1
by: Abdalla Fawaz El-Hawary | last post by:
I have a solution includes 2 projects the 1st one is a class library project and the 2nd is windows application. Normally i can use the classes wich in the 1st project(DLL) after add refrence for...
3
by: Edward | last post by:
Hello, Win VB6 i used doevents() to update my forms during a process, but for whatever reason this is changed in vb.net. Can someone help me with how this should work. Thanks, Edward
1
by: RSH | last post by:
I created a new Windows Form project and I created a simple richtextbox to write to and I am looping through a simple example but obviously the screen isn't updated it only shows the first...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
1
by: pcnerd | last post by:
I have VB.NET 2005 Express Edition. Is there a VB.NET equivalent to the "classic" VB's DoEvents? I searched the VB.NET Help & had no luck. In "classic" VB, DoEvents was used in code that might...
12
by: Justin | last post by:
I can attach my code if anyone wants to see it however I'll try to ask my question with some mark up code first. I'm having a problem terminating my process while using DoEvents. For example: ...
11
by: Don | last post by:
I have a WPF application in VB in VSTS 2008 RTM. I am trying to "blink" (momentarily clear) a field of data if the data is reloaded from the database to give the user some visual indication of the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.