Flash Form window

Flash window to alert user or attract attention

        [DllImport("user32.dll")]
        static extern Int32 FlashWindowEx(ref FLASHWINFO pwfi);

        [StructLayout(LayoutKind.Sequential)]
        public struct FLASHWINFO
        {
            public UInt32 cbSize;
            public IntPtr hwnd;
            public Int32 dwFlags;
            public UInt32 uCount;
            public Int32 dwTimeout;
        }
        // stop flashing
        Int32 FLASHW_STOP = 0;

        // flash the window title
        Int32 FLASHW_CAPTION = 1;

        // flash the taskbar button
        Int32 FLASHW_TRAY = 2;

        // 1 | 2
        Int32 FLASHW_ALL = 3;

        // flash continuously
        Int32 FLASHW_TIMER = 4;

        // flash until the window comes to the foreground
        Int32 FLASHW_TIMERNOFG = 12;

        public void Flash()
        {
            FLASHWINFO fw = new FLASHWINFO();

            fw.cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(FLASHWINFO)));
            fw.hwnd = this.Handle;
            fw.dwFlags = FLASHW_ALL;
            fw.uCount = UInt32.MaxValue;

            FlashWindowEx(ref fw);
        }

Download with Progressbar

Download something from internet and show progress using progressbar

Public Class Form1

    Private Sub downloadFile(ByVal sourcePath As string, ByVal destinationPath As string)
        Dim wc As New System.Net.WebClient()
        AddHandler wc.DownloadProgressChanged, AddressOf DownloadProgressCallback

        wc.DownloadFileAsync(New System.Uri(sourcePath), destinationPath)

        ' Uncomment this if you want to pause in this sub while the file downloads
        'While wc.IsBusy = True
        '    Application.DoEvents()
        'End While

    End Sub

    Private Sub DownloadProgressCallback(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs)
        ProgressBar1.Maximum = e.TotalBytesToReceive
        ProgressBar1.Value = e.BytesReceived
    End Sub

End Class