Dreamine.Threading.Wpf 1.0.1
이 패키지는 Worker Thread를 직접 생성하거나 제어하지 않습니다. `IDreamineThreadManager`의 상태만 관찰합니다.
로딩중...
검색중...
일치하는것 없음
ThreadInfoRow.cs
이 파일의 문서화 페이지로 가기
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Runtime.CompilerServices;
5using Dreamine.Threading.Models;
6
8{
25 public sealed class ThreadInfoRow : INotifyPropertyChanged
26 {
35 private DreamineThreadStatus _status;
44 private DreamineThreadPriority _priority;
53 private int _intervalMs;
62 private int? _coreIndex;
71 private bool _useAffinity;
80 private int _jobCount;
89 private long _cycleCount;
98 private DateTimeOffset? _startedAt;
107 private DateTimeOffset? _stoppedAt;
116 private string? _lastErrorMessage;
117
126 public event PropertyChangedEventHandler? PropertyChanged;
127
136 public string Name { get; }
137
146 public DreamineThreadStatus Status
147 {
148 get => _status;
149 private set => SetField(ref _status, value);
150 }
151
160 public DreamineThreadPriority Priority
161 {
162 get => _priority;
163 private set => SetField(ref _priority, value);
164 }
165
174 public int IntervalMs
175 {
176 get => _intervalMs;
177 private set => SetField(ref _intervalMs, value);
178 }
179
188 public int? CoreIndex
189 {
190 get => _coreIndex;
191 private set => SetField(ref _coreIndex, value);
192 }
193
202 public bool UseAffinity
203 {
204 get => _useAffinity;
205 private set => SetField(ref _useAffinity, value);
206 }
207
216 public int JobCount
217 {
218 get => _jobCount;
219 private set => SetField(ref _jobCount, value);
220 }
221
230 public long CycleCount
231 {
232 get => _cycleCount;
233 private set => SetField(ref _cycleCount, value);
234 }
235
244 public DateTimeOffset? StartedAt
245 {
246 get => _startedAt;
247 private set => SetField(ref _startedAt, value);
248 }
249
258 public DateTimeOffset? StoppedAt
259 {
260 get => _stoppedAt;
261 private set => SetField(ref _stoppedAt, value);
262 }
263
272 public string? LastErrorMessage
273 {
274 get => _lastErrorMessage;
275 private set => SetField(ref _lastErrorMessage, value);
276 }
277
286 public bool IsRunning => Status == DreamineThreadStatus.Running;
287
296 public bool IsPaused => Status == DreamineThreadStatus.Paused;
297
306 public bool IsFaulted => Status == DreamineThreadStatus.Faulted;
307
332 public ThreadInfoRow(DreamineThreadInfo info)
333 {
334 ArgumentNullException.ThrowIfNull(info);
335
336 Name = info.Name;
337 _status = info.Status;
338 _priority = info.Priority;
339 _intervalMs = info.IntervalMs;
340 _coreIndex = info.CoreIndex;
341 _useAffinity = info.UseAffinity;
342 _jobCount = info.JobCount;
343 _cycleCount = info.CycleCount;
344 _startedAt = info.StartedAt;
345 _stoppedAt = info.StoppedAt;
346 _lastErrorMessage = info.LastErrorMessage;
347 }
348
381 public bool UpdateFrom(DreamineThreadInfo info)
382 {
383 ArgumentNullException.ThrowIfNull(info);
384
385 var statusChanged = _status != info.Status;
386 var anyChanged = false;
387
388 anyChanged |= SetField(ref _status, info.Status, nameof(Status));
389 anyChanged |= SetField(ref _priority, info.Priority, nameof(Priority));
390 anyChanged |= SetField(ref _intervalMs, info.IntervalMs, nameof(IntervalMs));
391 anyChanged |= SetField(ref _coreIndex, info.CoreIndex, nameof(CoreIndex));
392 anyChanged |= SetField(ref _useAffinity, info.UseAffinity, nameof(UseAffinity));
393 anyChanged |= SetField(ref _jobCount, info.JobCount, nameof(JobCount));
394 anyChanged |= SetField(ref _cycleCount, info.CycleCount, nameof(CycleCount));
395 anyChanged |= SetField(ref _startedAt, info.StartedAt, nameof(StartedAt));
396 anyChanged |= SetField(ref _stoppedAt, info.StoppedAt, nameof(StoppedAt));
397 anyChanged |= SetField(ref _lastErrorMessage, info.LastErrorMessage, nameof(LastErrorMessage));
398
399 if (statusChanged)
400 {
404 }
405
406 return anyChanged;
407 }
408
457 private bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
458 {
459 if (EqualityComparer<T>.Default.Equals(field, value))
460 {
461 return false;
462 }
463
464 field = value;
465 OnPropertyChanged(propertyName);
466 return true;
467 }
468
485 private void OnPropertyChanged(string? propertyName)
486 {
487 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
488 }
489 }
490}
bool SetField< T >(ref T field, T value, [CallerMemberName] string? propertyName=null)