Changeset 8776
- Timestamp:
- 10/10/12 12:01:52 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/PickupDeliveryOptimization.cs
r8773 r8776 331 331 CancellationTokenSource cts; 332 332 333 private object threadLocker = new object();334 333 protected bool running; 335 334 336 335 public void Start(bool synchronized) { 337 336 running = true; 338 started = false;339 337 InitWaitHandle(synchronized); 338 339 EventWaitHandle wh = new EventWaitHandle(false, EventResetMode.ManualReset); 340 340 341 341 cts = new CancellationTokenSource(); 342 342 optThread = new Thread(delegate() { 343 lock (threadLocker) { 344 started = true; 345 } 343 wh.Set(); 346 344 Optimize(cts.Token); 347 345 }); … … 349 347 optThread.Start(); 350 348 351 while (!Started()) 352 Thread.Sleep(100); 349 wh.WaitOne(); 353 350 } 354 351 … … 364 361 } 365 362 366 private bool started;367 private bool Started() {368 bool result;369 lock (threadLocker) {370 result = started;371 started = false;372 }373 return result;374 }375 376 363 public bool Running() { 377 364 return optThread != null && optThread.IsAlive && running; … … 381 368 while (Running()) { 382 369 Thread.Sleep(100); 370 SignalWaitHandle(); 383 371 } 384 372 optThread = null;
Note: See TracChangeset
for help on using the changeset viewer.