Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Global Variables take a long time to load

Status
Not open for further replies.

mander23

MIS
Jan 30, 2005
28
US
I have a rather large program where I declare many global variables as so:
Public WithEvents master_rate_info As HYDRUS.MODEL.SuperTable = HYDRUS.CONTROL.DataClass.GetSimple("master_rate_info", strEnv, False)

. It takes over 30 seconds for all of these to be declared and therefore takes forever for my program to start. Is there a way to declare these asynchrously or a more effiecient way to do this. Thank you.
 
Well, if they are not actually needed at program start, you could just declare the variables globally:

Public WithEvents master_rate_info As HYDRUS.MODEL.SuperTable


Then you only instantiate the objects as they are needed:

master_rate_info = HYDRUS.CONTROL.DataClass.GetSimple("master_rate_info", strEnv, False)



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Yep, load them when you need them.


Christiaan Baes
Belgium

My Blog
"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
What i was trying to do is this.
declare globally:
master_rate_info = HYDRUS.CONTROL.DataClass.GetSimple("master_rate_info", strEnv, False)

i also have this declared globally:
Private Delegate Sub DefineTableHandler(ByRef tbl As Object, ByVal tablename As String)
Private DefineTable As DefineTableHandler = AddressOf DefineTableBegin

then at form_load I:
DefineTable.BeginInvoke(master_rate_info, "master_rate_info", Nothing, Nothing)

which this is invoked:
Private Sub DefineTableBegin(ByRef table As Object, ByVal TableName As String)
table = HYDRUS.CONTROL.DataClass.GetSimple(TableName, strEnv, False)
End Sub

I thought since i passes in the variable master_rate_info that it would assign that but it is still nothing after my delegate runs. Any help?
 
I would do it like this

Private WithEvents _master_rate_info As HYDRUS.MODEL.SuperTable
public readonly property master_rate_info
get
if _master_rate_info is nothing then
_master_rate_info = HYDRUS.CONTROL.DataClass.GetSimple("master_rate_info", strEnv, False)
return _master_rate_info
end if
end get
end property

Christiaan Baes
Belgium

My Blog
"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
OOPS

I meant this

Code:
Private WithEvents _master_rate_info As HYDRUS.MODEL.SuperTable
public readonly property master_rate_info
get
if _master_rate_info is nothing then
   _master_rate_info = HYDRUS.CONTROL.DataClass.GetSimple("master_rate_info", strEnv, False)
   return _master_rate_info
end if
end get
end property

Christiaan Baes
Belgium

My Blog
"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top