Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Slow drawing speed of WinForms (esp via COM interop)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil - 18 Jul 2006 15:57 GMT
Hi,

Has anybody experienced severe slow-down with the drawing speed of
WinForms? It's not fast at the best of time, but the particular
scenario I am having problems with is via COM interop and Excel.

The structure is:

 Excel VBA macro
    |
    V
 instantiate and call a COM wrapper class exposed
 by my assembly using ComVisible(true)
    |
    V
 Wrapper class instantiates the WinForm
 and displays it

The forms don't do anything special, they contain maybe 10-20
controls, including one or two grids, but you can sit there and watch
them paint themselves control-by-control.

I am using data binding, if that helps.

Any help to fix this will be very gratefully received, but even if you
have experienced something similar please reply so that I know I am
not alone!

--
Phil
Patrice - 18 Jul 2006 17:06 GMT
COM Interop is slow. I would minimize the number of calls (what is the
source you databind ?, do you have a single call to the .NET application ?).

I made something the other way round i..e uisng Excel from Windows. I's much
quicker :
- to copy data to Excel using a single cell (as an array) instead of copying
all separately
- to have the winform to create an Excel macro that is then transmitted and
executed in Excel (quicker than performing the layout from the Winforms with
the associated overhead for each call).

Signature

Patrice

> Hi,
>
[quoted text clipped - 26 lines]
> --
> Phil
Phil - 19 Jul 2006 12:12 GMT
>COM Interop is slow. I would minimize the number of calls (what is the
>source you databind ?, do you have a single call to the .NET application ?).

Patrice,

Yes, just essentially a call to ShowDialog(). I am gonna try it from
other applications eg a VB6 and see if that makes a difference, it
might be an Excel-specific problem.

--
Phil
Patrice - 19 Jul 2006 12:30 GMT
What I don't understand for now is if Excel is involved in the picture. Does
Excel just launch the form and the rest of the whole process is internal.
What is the source of the bindings ?

If 2.0 you can try Joris's suggestion with the "Shown" event...

Signature

Patrice

>>COM Interop is slow. I would minimize the number of calls (what is the
>>source you databind ?, do you have a single call to the .NET application
[quoted text clipped - 8 lines]
> --
> Phil
Phil - 20 Jul 2006 10:49 GMT
>What I don't understand for now is if Excel is involved in the picture. Does
>Excel just launch the form and the rest of the whole process is internal.

Yes, exactly. There are 2 lines of VBA behind a button in Excel.

>What is the source of the bindings ?

A typed DataSet - which has been loaded before the form is shown. I
have basically written an overload of ShowDialog() that does this:

public void ShowDialog(string SalesOrderNum) {
 load the dataset with 1 order for SalesOrderNum
 initialise data bindings
 set form caption to "New Order" or "Edit Order"
 ShowDialog(); // call standard form ShowDialog to display the window
}

So I am doing the majority of my work *before* I call ShowDialog, so I
am surprised at the slow painting, everything should be there by then.

It may be that I should use the events....perhaps doing it the way I
am is non-standard and is causing the problem.

>If 2.0 you can try Joris's suggestion with the "Shown" event...

--
Phil
Joris Zwaenepoel - 19 Jul 2006 10:02 GMT
Hi Phil,

In cases like that, I often display the form first, without the
"databinding".  In the Form_LOad event, I activate a Forms Timer with an
interval of maybe 20 ms, and then when the timer elapses I fill in all the
controls (and disable the timer to make sure it only elapses once).  This
speeds up the loading of the form and the painting, so the user sees an empty
screen much faster.  Then the data is loaded with a small delay, ususally not
disturbing for the user.

This doesn't make it faster, but it looks faster and certainly much nicer,
and it is a much better experienc for the user.

Hope this helps,

Joris

> Hi,
>
[quoted text clipped - 26 lines]
> --
> Phil
Phil - 19 Jul 2006 12:14 GMT
>Hi Phil,
>
[quoted text clipped - 12 lines]
>
>Joris

Joris,

I'll try it later this week (have to get ready for a demo now....)
Thanks for the suggestion.

--
Phil

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.