Advertisement
Guest User

Screen Delayer

a guest
Oct 18th, 2016
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.75 KB | None | 0 0
  1. Public Class Form1
  2.     Dim bmpScreenCapture = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
  3.     Dim DelayNextScreen = Environment.TickCount
  4.     Dim g As Graphics = Graphics.FromImage(bmpScreenCapture)
  5.     Dim CapturerThread As New System.Threading.Thread(AddressOf Capturer)
  6.     Dim ShowImage As Bitmap
  7.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  8.         CapturerThread.IsBackground = True
  9.         CapturerThread.Start()
  10.     End Sub
  11.     Delegate Sub UpdateImage()
  12.     Sub UpdateImageGUI()
  13.         PictureBox1.Image = ShowImage
  14.     End Sub
  15.     Dim s As New UpdateImage(AddressOf UpdateImageGUI)
  16.     Sub Capturer()
  17.         Do
  18.             g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, bmpScreenCapture.Size, CopyPixelOperation.SourceCopy)
  19.             Dim nf As Bitmap = bmpScreenCapture.Clone()
  20.             Dim t As New System.Timers.Timer
  21.             t.Interval = 5000
  22.             t.AutoReset = False
  23.             ShowImage = nf.Clone()
  24.             AddHandler t.Elapsed, (Sub()
  25.                                        ShowImage = nf.Clone()
  26.                                        nf.Dispose()
  27.                                        nf = Nothing
  28.                                        System.GC.Collect()
  29.                                        System.GC.WaitForPendingFinalizers()
  30.                                        Try
  31.                                            Invoke(s)
  32.                                        Catch ex As Exception
  33.                                        End Try
  34.                                    End Sub)
  35.             t.Start()
  36.             System.Threading.Thread.Sleep(50) 'Framerate: 20 fps
  37.         Loop
  38.     End Sub
  39. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement