我在VB中有这些行,想知道它们的C#等价物。我已经使用在线转换器转换了代码,但我不确定。所以需要一些专家建议
Dim PlotLensProfileThreadDelegate As New ThreadStart(AddressOf PlotLensProfileThreadFunction)
Dim PlotLensProfileThread As New Thread(PlotLensProfileThreadDelegate)
Dim PlotLensPlanThreadDelegate As New ThreadStart(AddressOf PlotLensPlanThreadFunction)
Dim PlotLensPlanThread As New Thread(PlotLensPlanThreadDelegate)
在线工具导致了这个
ThreadStart PlotLensProfileThreadDelegate = new ThreadStart(PlotLensProfileThreadFunction);
Thread PlotLensProfileThread = new Thread(PlotLensProfileThreadDelegate);
ThreadStart PlotLensPlanThreadDelegate = new ThreadStart(PlotLensPlanThreadFunction);
Thread PlotLensPlanThread = new Thread(PlotLensPlanThreadDelegate);
我在上面的代码中遇到了错误,所以我做了类似这样的工作。
ThreadStart PlotLensProfileThreadDelegate = new ThreadStart(new FrmSoftJobProcess(). PlotLensProfileThreadFunction); //This has to be revisited again
Thread PlotLensProfileThread = new Thread(new FrmSoftJobProcess(). PlotLensProfileThreadDelegate);
ThreadStart PlotLensPlanThreadDelegate = new ThreadStart(new FrmSoftJobProcess().PlotLensPlanThreadFunction);
Thread PlotLensPlanThread = new Thread(new FrmSoftJobProcess().PlotLensPlanThreadDelegate);
函数 PlotLensProfileThreadFunction 在同一个类FrmSoftJobProcess中定义,并且非静态。因为它是非静态的 - 编译器不允许我访问它所以我不得不沿着类名称
private void PlotLensProfileThreadFunction()
{
Mold_Power_Suite.Model.FrontEndStructures.ErrorFlagType ErrorFlag =FrontEndStructures. InitErrorFlag();
Graphics InMedia = this.PicLensPlot.CreateGraphics();
PlotLensProfileThread PlotRef = new PlotLensProfileThread();
// 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();
}
}
只是想知道我采取的正确方法还是可能有别的东西?
我不知道 AddressOf 运算符在VB代码中的位置