public static void UpdateNotifyIconProgress(NotifyIcon ni, int progress) { if (ni != null) { using (Bitmap img = (Bitmap)GraphicsMgr.DrawProgressIcon(UploadManager.GetAverageProgress())) { IntPtr hicon = img.GetHicon(); ni.Icon = Icon.FromHandle(hicon); NativeMethods.DestroyIcon(hicon); } } }