Imports System.Threading
Imports System.Drawing

Public Class ImageProxy
  Private done As Boolean
  Private tm As Timer
  '-----
  Public Sub New()
    done = False
    'Ustaw interwał timera na 5 sekund
    tm = New Timer(New TimerCallback(AddressOf tCallback), _
                   Me, 5000, 0)
  End Sub
  '-----
  Public Function isReady() As Boolean
    Return done
  End Function
  '-----
  Public Function getImage() As Image
    Dim img As Imager
    'Zwraca instancję obrazka tymczasowego lub docelowego
    If isReady() Then
      img = New FinalImage()
    Else
      img = New QuickImage()
    End If
    Return img.getImage
  End Function
  '-----
  Public Sub tCallback(ByVal obj As Object)
    'Ustaw flagę done i wyłącz timer
    done = True
    tm.Dispose()
  End Sub
End Class
