Guest User

Untitled

a guest
Jan 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Threading
  3. Imports System.Threading.Tasks
  4.  
  5. Friend Module Optimise
  6.  
  7. Friend Results() As Single
  8.  
  9. Sub Go()
  10. Parallel.Invoke(New Action(AddressOf Optimise), New Action(AddressOf ExportResults))
  11. End Sub
  12.  
  13. Sub Optimise()
  14.  
  15. redim results(1000)
  16.  
  17. For i = 1 To 1000
  18. 'results(i) = do some calcs
  19. 'do I need to lock results() somehow? Or as ExportResults() is the only other thing accessing am I OK to leave unlocked?
  20. Next
  21.  
  22. End Sub
  23.  
  24. Sub ExportResults()
  25.  
  26. 'how can this thread monitor results()?
  27. '(is results locked?)
  28. 'How can it access results without interupting optimise() thread?
  29.  
  30. End Sub
  31.  
  32. End Module
Add Comment
Please, Sign In to add comment