471,310 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Conversion from VB6 to VB.NET Architectural Question

I have an architectural issue that I have been working on for quite awhile
now and I would like another person's point of view. This issue involves the
conversion of a VB6 app to VB.NET.

In this VB6 app, the original programmer used 5 timers to periodically scan
a document, process it, and display thumbnail images of the scanned
document. These 5 timers implement 5 different subroutines that enable this
process. In my conversion of this app to VB.NET, I have investigated and
implemented threads, threadpools, timers, and now async delegates with
varying degrees of success (in regards to application performance.)

What I am trying to do is to try to simulate the original VB6 timers (that
implement the 5 different routines) to the new .NET approach as follows:

Original New
VB6 App VB.NET App
-------------------------------------------
Timer 1 Main Threading Timer - (Encapsulates Threadpools 2 thru 5)
Timer 2 Threadpool 1 - (Scans document)
Timer 3 Threadpool 2 - (Executes another program as a process for
image character recognition)
Timer 4 Thread pool 3 - Display Thumbnail images
Timer 5 Threadpool 4 - Exits after the above Threadpools are done

This worked but was so CPU intensive that it did not allow me to implement
other features. For example, once the app started running, it was polling
the scanner so much that the UI did not allow me select the scanned bitmap
images to expand them. When I varied the Threading Timer values, I was able
to expand the bitmap images but it was still very slow. I understand that
win forms are not thread safe and I did implement the code necessary (ie.
invoke required...etc.).

I understand that using Async delegates can also do the polling necessary
and some have stated that it is "cleaner" than using Timers and Threadpools
in this case. Architecturally speaking, what would be the best way to have
this converted to VB.NET and still have the same functionality and
responsiveness?? What other approach would I use other than what I have
described?? Since responsiveness is the key, is using Async delegates a
viable option??
Thanks so much in advance!
Viet



Nov 21 '05 #1
2 1159
Sorry cant be of much help architecturaly but here are my 2 cents.

Did you consider using one of the many Timers available in .NET just to make
sure that your app gets going atleast for the time being.

One more thing, u mentioned "when I varied the Threading Timer values", what
exactly do you mean by this. I assume your are using Sleep to make the
polling wait for a while.

HTH
rawCoder

"Viet" <vp**@starcalif.com> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
I have an architectural issue that I have been working on for quite awhile
now and I would like another person's point of view. This issue involves the conversion of a VB6 app to VB.NET.

In this VB6 app, the original programmer used 5 timers to periodically scan a document, process it, and display thumbnail images of the scanned
document. These 5 timers implement 5 different subroutines that enable this process. In my conversion of this app to VB.NET, I have investigated and
implemented threads, threadpools, timers, and now async delegates with
varying degrees of success (in regards to application performance.)

What I am trying to do is to try to simulate the original VB6 timers (that
implement the 5 different routines) to the new .NET approach as follows:

Original New
VB6 App VB.NET App
-------------------------------------------
Timer 1 Main Threading Timer - (Encapsulates Threadpools 2 thru 5) Timer 2 Threadpool 1 - (Scans document)
Timer 3 Threadpool 2 - (Executes another program as a process for image character recognition)
Timer 4 Thread pool 3 - Display Thumbnail images
Timer 5 Threadpool 4 - Exits after the above Threadpools are done
This worked but was so CPU intensive that it did not allow me to implement
other features. For example, once the app started running, it was polling
the scanner so much that the UI did not allow me select the scanned bitmap
images to expand them. When I varied the Threading Timer values, I was able to expand the bitmap images but it was still very slow. I understand that
win forms are not thread safe and I did implement the code necessary (ie.
invoke required...etc.).

I understand that using Async delegates can also do the polling necessary
and some have stated that it is "cleaner" than using Timers and Threadpools in this case. Architecturally speaking, what would be the best way to have
this converted to VB.NET and still have the same functionality and
responsiveness?? What other approach would I use other than what I have
described?? Since responsiveness is the key, is using Async delegates a
viable option??
Thanks so much in advance!
Viet


Nov 21 '05 #2
Rawcoder,
Thanks for your reply. I have considered the many Timers available in .NET
but the problem that I was having was that once the app started executing
with the timer, it was difficult to do other things since the timer was
taking a majority of the CPU time (due to all the polling). I considered
executing the timer as a different Thread but I still needed to keep the
constant scanner polling functionality and hence my problem: how to keep the
scanner constantly polling but still keep the app UI responsive to user
demands without loss of responsiveness. I know that there has to be a way
since alot of apps implement this multitasking feature.

In regards to the second paragraph, my original code for the threading timer
was as follows:

Dim stateTimer As System.Threading.Timer = New
System.Threading.Timer(timerDelegate, evt, TimeSpan.FromSeconds(3),
TimeSpan.FromSeconds(5))

By changing the values, one can determine how fast or how slow polling can
be.

The answer is probably something simple that I am overlooking or something
that I am implementing incorrectly in current design.

Thanks,
Viet


"rawCoder" <ra******@hotmail.com> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
Sorry cant be of much help architecturaly but here are my 2 cents.

Did you consider using one of the many Timers available in .NET just to make sure that your app gets going atleast for the time being.

One more thing, u mentioned "when I varied the Threading Timer values", what exactly do you mean by this. I assume your are using Sleep to make the
polling wait for a while.

HTH
rawCoder

"Viet" <vp**@starcalif.com> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
I have an architectural issue that I have been working on for quite awhile now and I would like another person's point of view. This issue involves the
conversion of a VB6 app to VB.NET.

In this VB6 app, the original programmer used 5 timers to periodically

scan
a document, process it, and display thumbnail images of the scanned
document. These 5 timers implement 5 different subroutines that enable

this
process. In my conversion of this app to VB.NET, I have investigated and
implemented threads, threadpools, timers, and now async delegates with
varying degrees of success (in regards to application performance.)

What I am trying to do is to try to simulate the original VB6 timers (that implement the 5 different routines) to the new .NET approach as follows:

Original New
VB6 App VB.NET App
-------------------------------------------
Timer 1 Main Threading Timer - (Encapsulates Threadpools 2 thru 5)
Timer 2 Threadpool 1 - (Scans document)
Timer 3 Threadpool 2 - (Executes another program as a process

for
image character recognition)
Timer 4 Thread pool 3 - Display Thumbnail images
Timer 5 Threadpool 4 - Exits after the above Threadpools are

done

This worked but was so CPU intensive that it did not allow me to

implement other features. For example, once the app started running, it was polling the scanner so much that the UI did not allow me select the scanned bitmap images to expand them. When I varied the Threading Timer values, I was

able
to expand the bitmap images but it was still very slow. I understand that win forms are not thread safe and I did implement the code necessary (ie. invoke required...etc.).

I understand that using Async delegates can also do the polling necessary and some have stated that it is "cleaner" than using Timers and

Threadpools
in this case. Architecturally speaking, what would be the best way to have this converted to VB.NET and still have the same functionality and
responsiveness?? What other approach would I use other than what I have
described?? Since responsiveness is the key, is using Async delegates a
viable option??
Thanks so much in advance!
Viet



Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Russell Reagan | last post: by
5 posts views Thread by Vijai Kalyan | last post: by
26 posts views Thread by David W. Fenton | last post: by
31 posts views Thread by Bjørn Augestad | last post: by
2 posts views Thread by Alex Sedow | last post: by
3 posts views Thread by clintonG | last post: by
reply views Thread by clintonG | last post: by
21 posts views Thread by REH | last post: by
reply views Thread by rosydwin | last post: by

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.