c# - Error accessing ThreadStart object inside a function -


i stuck @ peculiar issue , want in resolving this.

i have following code below

    public partial class frmsoftjobprocess : form         {             private bool instancefieldsinitialized = false;             public frmsoftjobprocess()             {                 initializecomponent();                 load += frmjobprocess_load;                 formclosing += frmjobprocess_formclosing;                 if (!instancefieldsinitialized)                 {                     initializeinstancefields();                     instancefieldsinitialized = true;                 }              }             private void initializeinstancefields()             {                 plotlensprofilethreaddelegate = new threadstart(plotlensprofilethreadfunction);                 plotlensprofilethread = new thread(plotlensprofilethreaddelegate);                 plotlensplanthreaddelegate = new threadstart(plotlensplanthreadfunction);                 plotlensplanthread = new thread(plotlensplanthreaddelegate);             }             private threadstart plotlensprofilethreaddelegate;             private thread plotlensprofilethread;             private threadstart plotlensplanthreaddelegate;             private thread plotlensplanthread; ------------------- ----------------------- } 

the class above has following function

 private   void plotlensprofilethreadfunction()         {             mold_power_suite.model.frontendstructures.errorflagtype errorflag =frontendstructures. initerrorflag();             graphics inmedia = this.piclensplot.creategraphics();             plotlensprofilethread plotref = new plotlensprofilethread(); // how can access this? cant create object field.             // var plotref = plotlensprofilethread;             try             {                 plotref.threadingrphref = inmedia;                 plotref.threadinconcavepaths = concavepaths;                 plotref.threadinconvexpaths = convexpaths;                 plotref.threadplotoptions = plotoptions.profileview;                 plotref.threadstepsixdata = jobdata.stepsixdata;                 plotref.threadstepfivedata = jobdata.stepfivedata;                 plotref.threadstepfourdata = jobdata.stepfourdata;                 plotref.threadstepthreedata = jobdata.stepthreedata;                 plotref.threadsteptwodata = jobdata.steptwodata;                 plotref.errorflag = errorflag;                 plotref.meridianconcave = meridianconcave;                 plotref.meridianedge = meridianedge;                 plotref.meridianconvex = meridianconvex;                 zedgraphcontrol1.graphpane.curvelist.clear();                 plotref.zedgraphtype = zedgraphcontrol1;                 plotref.plotlensprofile();             }             catch (system.threading.threadabortexception e)             {                 system.threading.thread.resetabort();             }         } 

the whole source code in vb , has been converted c# using telerik online tool.

i adding original method in vb better understanding

private sub plotlensplanthreadfunction()         dim errorflag errorflagtype = initerrorflag()         dim inmedia graphics = me.piclensplot.creategraphics         dim plotref new plotlensplanthread()         try             plotref.threadingrphref = inmedia             plotref.threadinconcavepaths = concavepaths             plotref.threadinconvexpaths = convexpaths             plotref.threadplotoptions = plotoptions.planview             plotref.threadstepsixdata = jobdata.stepsixdata             plotref.threadstepfourdata = jobdata.stepfourdata             plotref.errorflag = errorflag             plotref.meridianconcave = meridianconcave             plotref.meridianedge = meridianedge             plotref.meridianconvex = meridianconvex             plotref.plotlensplan()         catch ex exception             system.threading.thread.resetabort()         end try     end sub 

i getting error in c# statement plotlensprofilethread plotref = new plotlensprofilethread(); error plotlensprofilethread' 'field' used 'type'

can me out ?

thanks

you getting error in said line plotlensprofilethread plotref = new plotlensprofilethread(); cause in class defined thread instance same name can seen below

thread plotlensprofilethread = new thread(new frmsoftjobprocess(), .... 

in method, plotlensprofilethread custom class or something? way should use different name either thread or type.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -