0

I have created on Data Extractor application in Visual Studio 2019(VB.NET) which is scheduled to extract data from Access DB(updating by other software) file and convert to Text file in every 2 seconds. Meanwhile it also updates many controls of the form such as chart control, Progress Bar and Text box. I have published My application on .NET Framework 4.7.2

Issue: Application is working Completely fine for almost an hour after initiation but its control started to fade and ultimately disappear after some time(As you can see in the image). Eventually it stopped responding and I have to close and reopen.

enter image description here

Ironically When I checked My text file during application under Hang condition, it was continuously updating with data from DB file. I suspected that code is performing its duty but Windows Form loses its aesthetics over the time. Why it is happening?

what could be the possible reason of occurrence? (I tried to clean the solution and built it again but gain no success)

I used CircularPeogressBar from https://github.com/RamsinChaabian/CircleProgressBar

Below is code from designer window

'CircularProgressBar1
    '
    Me.CircularProgressBar1.AccessibleRole = System.Windows.Forms.AccessibleRole.None
    Me.CircularProgressBar1.AnimationFunction = WinFormAnimation.KnownAnimationFunctions.Liner
    Me.CircularProgressBar1.AnimationSpeed = 0
    Me.CircularProgressBar1.BackColor = System.Drawing.Color.Transparent
    Me.CircularProgressBar1.Font = New System.Drawing.Font("Microsoft Sans Serif", 72.0!, System.Drawing.FontStyle.Bold)
    Me.CircularProgressBar1.ForeColor = System.Drawing.Color.FromArgb(CType(CType(64, Byte), Integer), CType(CType(64, Byte), Integer), CType(CType(64, Byte), Integer))
    Me.CircularProgressBar1.InnerColor = System.Drawing.Color.Transparent
    Me.CircularProgressBar1.InnerMargin = 2
    Me.CircularProgressBar1.InnerWidth = -1
    Me.CircularProgressBar1.Location = New System.Drawing.Point(313, 132)
    Me.CircularProgressBar1.MarqueeAnimationSpeed = 0
    Me.CircularProgressBar1.Maximum = 60
    Me.CircularProgressBar1.Name = "CircularProgressBar1"
    Me.CircularProgressBar1.OuterColor = System.Drawing.Color.FromArgb(CType(CType(87, Byte), Integer), CType(CType(87, Byte), Integer), CType(CType(87, Byte), Integer))
    Me.CircularProgressBar1.OuterMargin = -25
    Me.CircularProgressBar1.OuterWidth = 25
    Me.CircularProgressBar1.ProgressColor = System.Drawing.Color.Cyan
    Me.CircularProgressBar1.ProgressWidth = 20
    Me.CircularProgressBar1.SecondaryFont = New System.Drawing.Font("Microsoft Sans Serif", 36.0!)
    Me.CircularProgressBar1.Size = New System.Drawing.Size(156, 156)
    Me.CircularProgressBar1.StartAngle = -90
    Me.CircularProgressBar1.Step = 1
    Me.CircularProgressBar1.SubscriptColor = System.Drawing.Color.Transparent
    Me.CircularProgressBar1.SubscriptMargin = New System.Windows.Forms.Padding(10, -35, 0, 0)
    Me.CircularProgressBar1.SubscriptText = ""
    Me.CircularProgressBar1.SuperscriptColor = System.Drawing.Color.Transparent
    Me.CircularProgressBar1.SuperscriptMargin = New System.Windows.Forms.Padding(10, 35, 0, 0)
    Me.CircularProgressBar1.SuperscriptText = ""
    Me.CircularProgressBar1.TabIndex = 24
    Me.CircularProgressBar1.TextMargin = New System.Windows.Forms.Padding(8, 8, 0, 0)

- Do I have to code entire CircularProgressBar Control to get rid of this issue or is there a way out available to tackle this problem?

- If proper dispose is the issue then how we can dispose them efficiently without leaking graphics resources?

Kharanshu
  • 21
  • 3
  • This is usually caused by Graphics objects not correctly disposed (you run out GDI+ handles). You should show at least the main Graphics procedures of the Control that disappears first (the *progress bar*, apparently). – Jimi May 28 '20 at 17:23
  • Yes @Jimi , Apparently CirclarProgressBar is quite susceptible of this disappearing phenomenon. So how can I dispose Graphic Objects correctly? – Kharanshu May 28 '20 at 17:32
  • *You should show at least the main Graphics procedures of the Control that...* – Jimi May 28 '20 at 17:33
  • @Jimi. CircularProgressBar is control I used from [link](https://github.com/RamsinChaabian/CircleProgressBar) – Kharanshu May 28 '20 at 19:01
  • All right. Do you see all those `var obj_pen = new Pen(Color.GreenYellow);`, `var ft = new StringFormat();`, `new SolidBrush(Color.Gray)` (a number of these) etc.? These (and probably others) are all disposable objects, you (well, the author) cannot just declare them without calling Dispose() on them. Those are GDI+ resources that the Garbage Collector has a really hard time to collect since you have a close loop that draws the Circular Progressbar. In practice, that UserControl is *leaking* Graphics resources. – Jimi May 28 '20 at 21:43
  • See, for example [here](https://stackoverflow.com/a/54139910/7444103) or [here](https://stackoverflow.com/a/51435842/7444103) how those objects are handled. See all those `using (...)` lines? Do the same thing with your UserControl. – Jimi May 28 '20 at 21:43
  • Yes as Jimi said. Actually the Graphics objects not disposed at all. I had a peek. –  May 28 '20 at 21:43
  • Nice timing bud. –  May 28 '20 at 21:44
  • yeah I can't challenge you on that. Now Mr. @Kharanshu paste the code here maybe we could offer something better. –  May 28 '20 at 21:48
  • @jimi is there a way to call dispose() with existing CircularProgressBar control or I need to code it from scratch? – Kharanshu May 30 '20 at 05:15
  • You have to modify the source code. You have it, so that's just a matter of editing some lines of code. – Jimi May 30 '20 at 12:51
  • @jimi Thanks for the support so far. I am new to VB.NET, can you please guide me in detecting and changing source code of CircularProgressBar? – Kharanshu May 31 '20 at 03:48
  • I've already done that. See the comment that begins with *All right. Do you see all those var obj_pen = new Pen(Color.GreenYellow); ...* and the one that follows. – Jimi May 31 '20 at 10:04

0 Answers0