I have created a Visual Basic .NET application that takes a screenshot every second and saves it to a file screenshot.jpg And I also created a server that serves the screenshot.jpg file every second. But the problem is that sometimes I see half of the picture (probably because it hasn't finished drawing yet). Is there a way around this problem? I wonder how webcams offer that smooth stream. Does it mean my screenshot capture program is too slow?
Here is my application
' Take screenshot every second
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Dim bmp As Bitmap = ScreenCap()
    bmp.Save(Application.StartupPath & "\screenshot.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
    bmp.Dispose()
End Sub
You can see the full project on Github: https://git.io/Jv4TL
And here is the front end code
<html>
<body>
    <img class="screenshot" src="screenshot.jpg">
    <script>
        setInterval(() => {
            document.querySelector('.screenshot').src =
                'screenshot.jpg?id=' + Math.random(0, 1000)
        }, 1000)
    </script>
</body>
</html>
