Addin Form - Delays

Addin Form - Delays

NachoShaw
Advisor Advisor
712 Views
11 Replies
Message 1 of 12

Addin Form - Delays

NachoShaw
Advisor
Advisor

Hi

 

Im close to completing my very long awaited addin. I have noticed though that the form delays up to 6-7 seconds when i load it. I would most definately prefer it to load immediately when i click the button.

 

In my AddinGlobal i create the member ready for its instance like this:

 

Public Shared fForm As frmMain

 

In my ButtonActions i create the instance like this:

 

 AddinGlobal.fForm = New frmMain
AddinGlobal.fForm.Show()

I dont have anything in my Load Event but i do have a Backgroundworker running to call a large function while the form is loading / loaded. Is there anything i can do to improve the loading time of the form? I am currently calling my BackgroundWorker in the forms Shown event so it shouldnt even be this slowing it down as its not called until the form is shown.

 

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
713 Views
11 Replies
Replies (11)
Message 2 of 12

smilinger
Advisor
Advisor

I guess inventor is mostly a single threaded application, if your large function is doing something about inventor, then definitely you will be blocked until the work is done.

0 Likes
Message 3 of 12

Frederick_Law
Mentor
Mentor

Test your addin without Background loader and see if the form show faster.

Find out why and where it is slow then see how to fix it.

Run in debug and step through the program to see which part is slow.

0 Likes
Message 4 of 12

NachoShaw
Advisor
Advisor

Run in debug and step through the program to see which part is slow.

 

Hi

 

going to sound stupid now.... If its an addin (DLL), how can i run that in debug and step through it? I thought i had to build it and run inventor every time i wanted to test progress. Havent found a way of stepping through a DLL

 

 

cheers

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 6 of 12

NachoShaw
Advisor
Advisor

Hi

 

Well, i turned everything off that was being called and it still took exactly the same amount of time. Weirdly though, this only happens once. On my close event, i dispose the form and when i click my button again to invoke the form, it loads in a second vs 5 seconds on the first time.

 

so, the delay is a 1 time occurrence only when it has been run first.....

 

When my addin loads, i have this:

 

Dim fForm as frmMain

 

when i click my button, this code is behind it:

 

AddinGlobal.fForm = New frmMain

 

i cant see why there would be an initial delay but after that, no delays....

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 7 of 12

smilinger
Advisor
Advisor
0 Likes
Message 8 of 12

NachoShaw
Advisor
Advisor

Well, it turns out that if i change the code, i lose the delay

 

in my AddinGlobal, i change this:

 

Dim fForm as frmMain

 

to

 

Dim fForm As New frmMain

 

and in my button code, change this:

 

'AddinGlobal.fForm = New frmMain

AddinGlobal.fForm.Show

 

however, i dispose the form when i close it to save memory and as its disposed, it no longer exists (which is why i did it the original method)

 

whats the best method of maintaining the form to no load into memory but leave it accessible after disposing?

 

 

 

 

cheers

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 9 of 12

NachoShaw
Advisor
Advisor

i dont do anything crazy in my Load Event, i only add a UserControl to a Panel. The backgroundWorker is the biggest work and thats called in the Form Shown event

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 10 of 12

NachoShaw
Advisor
Advisor

How are other developers handling the form in their addin? Are you guys just loading in from the start or is there a special way to get this working correctly?

 

 

 

cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 11 of 12

Frederick_Law
Mentor
Mentor

This is my addin to set Material for all Parts in Assembly.

When the form show, it'll load all Materials in a ListBox.

I took about 3 sec to load on first run, On my laptop. 2 core i7, 4GB RAM.

 

In Data Region:

Private m_SetMat As f_SetMat

 

In Ribbon Button OnExecute:

m_SetMat = New f_SetMat

m_SetMat.ShowDialog()

m_SetMat.Dispose()

 

What you have in the the Form's Activated Sub?

 

I'm targeting .Net 4.7.1 for IV2017.

0 Likes
Message 12 of 12

NachoShaw
Advisor
Advisor

Hi

 

I get the same delay even when no events are fired. I commented out all of the code and the delay still occurs. On another thread, i read that it could be because my form is shared. I declared it as shared because in another module & class, i specifically need to access some controls and without the form being shared, i cannot access the controls.

 

i guess ultimately i could move all of the code into the form but i didnt want it to get cluttered. Im happy to move all module code to the form and keep all classes as-is

 

i'll look at the issues again later

 

 

 

cheers

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes