【发布时间】:2016-06-30 12:48:36
【问题描述】:
我遇到了一个特殊的问题,需要一些帮助来解决这个问题。
我有下面的代码
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;
-------------------
-----------------------
}
上面的类有如下功能
private void PlotLensProfileThreadFunction()
{
Mold_Power_Suite.Model.FrontEndStructures.ErrorFlagType ErrorFlag =FrontEndStructures. InitErrorFlag();
Graphics InMedia = this.PicLensPlot.CreateGraphics();
PlotLensProfileThread PlotRef = new PlotLensProfileThread(); // how can I access this? I cant create object as its a 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();
}
}
整个源代码在 VB 中,并已使用 Telerik Online Tool 转换为 C#。
我在VB中添加原始方法以便更好地理解
Private Sub PlotLensPlanThreadFunction()
Dim ErrorFlag As ErrorFlagType = InitErrorFlag()
Dim InMedia As Graphics = Me.PicLensPlot.CreateGraphics
Dim PlotRef As 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 As Exception
System.Threading.Thread.ResetAbort()
End Try
End Sub
我在 C# 语句中遇到错误 PlotLensProfileThread PlotRef = new PlotLensProfileThread(); 错误是 PlotLensProfileThread' 是一个“字段”,但用作“类型”
谁能帮帮我?
谢谢
【问题讨论】: