private void LoopDoingVOID(object sender, object e) { if (OldWaitTime != WaitTime) { OldWaitTime = WaitTime; dt.Interval = new TimeSpan(0, 0, 0, 0, WaitTime); } StateSet(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (!Equals(OSTC, STC)) { SPGrid_TR01_SPSet = STC.V; SPGrid_TR01_PressSet(STC.MR, STC.ER, STC.BC, STC.BP); SPGrid_TR01_TimeSet((byte)STC.Hour, (byte)STC.Minute, (byte)STC.Second); SPGrid_TR01_CurrentSet = STC.I; SPGrid_TR01_LocationSet = STC.Z; OSTC = STC; } if (!Equals(OHDC, HDC)) { SPGrid_TR01_ReverserSet = HDC.R; SPGrid_TR01_HandleSet(HDC.B, HDC.P); OHDC = HDC; } if (!Equals(oIsDoorClosed, IsDoorClosed)) { SPGrid_TR01_IsDoorClosed = IsDoorClosed; oIsDoorClosed = IsDoorClosed; } }
public static void Run() { // Create structure instance and store it in the named data slot ApplicationData appData = new ApplicationData(); Thread.SetData(Thread.GetNamedDataSlot("appDataSlot"), appData); // Call another method that will use this structure HandleClass.MethodB(); // When done, free this data slot Thread.FreeNamedDataSlot("appDataSlot"); }
public static void MethodB() { // Get the instance from the named data slot ApplicationData storedAppData = (ApplicationData)Thread.GetData( Thread.GetNamedDataSlot("appDataSlot")); // Modify the ApplicationData // When finished modifying this data, store the changes back into // into the named data slot Thread.SetData(Thread.GetNamedDataSlot("appDataSlot"), storedAppData); // Call another method that will use this structure HandleClass.MethodC(); }
private void StateSet(double TrainLocation, float Speed, float BC, float MR, float ER, float BP, float SAP, float Current, int PNotch, int BNotch, int Reverser, int Door, int TimeHH, int TimeMM, int TimeSS, int TimeMS) { STC = new StateClass() { Z = TrainLocation, BC = BC, BP = BP, ER = ER, Hour = TimeHH, I = Current, Minute = TimeMM, MR = MR, MSecond = TimeMS, SAP = SAP, Second = TimeSS, V = Speed }; HDC = new HandleClass() { B = BNotch, P = PNotch, R = Reverser }; if (Door == 1) { IsDoorClosed = true; } else { IsDoorClosed = false; } }
public static void StoreThreadDataPrivately() { HandleClass.Run(); }