R.D Ip

R.D Ip

  • NA
  • 76
  • 7.6k

how to decrease time of long running method in c#(windows form)

Mar 19 2021 1:57 AM
I am trying to decrease a form load time 
 
Main.cs
  1. private void UTMaster_ToolClick(object sender, ToolClickEventArgs e)  //when I click on tag then this will call  
  2. {  
  3.   OrganisationMethod(sender,e);  
  4. }  
  1. private void OrganisationMethod(object sender, ToolClickEventArgs e)  
  2. {  
  3.    Form frms = (Form)Activator.CreateInstance(Type.GetType(strtagname));  
  4.    Type ObjType = frms.GetType();  
  5.    MethodInfo method = ObjType.GetMethod("ShowOrganisationForm"); //ShowOrganisationForm is a form  
  6.      
  7.       
  8.    ParameterInfo[] Arrayparams = method.GetParameters();  
  9.   
  10.    if (Arrayparams.Length == 0)  
  11.    {  
  12.       method.Invoke(frms, new object[0]);  
  13.    }  
  14.    else  
  15.    {  
  16.        //frms.Load += new (method);  
  17.        object[] paramsArray;  
  18.   
  19.        paramsArray = new object[] { e.Tool.propertytag.Tag.ToString() };  
  20.   
  21.        method.Invoke(frms, paramsArray);  
  22.     
  23.    }  
  24. }  
organiseform.cs
  1. public void ShowOrganisationForm()  
  2. {   
  3.       DataSetControl();     //this method take too much time to load
  4.    this.Show();  
  5. }  
  1. private void DataSetControl()  
  2. {  
  3.    //multiple combox fill code here  
  4. }  
I am working with windows form 
 
I am trying to decrease the form load time but not work please help

Answers (9)