ProgressBar Nil

Hi, I have two of my softwares which use ProgressBar, but just to show it (indeterminate) as I don’t know how long will be the process.
In one program, ProgressBar appears when I copy file(s). It’s a synchronisation program, I check all files in 2 folders and I copy those whoo need to (ProgressBar.visible is set to false and True periodically).
In other program I send email(s), if I have an error I try again, then the progressBar.visible is set to false and True again.

In both program I have sometimes Nil Objection. I added in my Code :
If not(MyProgressBar = Nil) Then MyProgressBar = True/False

I tried to reproduce the bug in a example :
But I don’t reach to get the Nil objection.
Did one of you see this bug? Did you find how to reproduce it in order to report the bug?

It’s possible for a control instance to be nil when a window is in the process of closing. If you update the progress bar from an external source or from a Timer or Thread this can happen.

Instead of checking for nil, I suggest wrapping that code in a try-catch block like this:

  MyProgressBar.visible = True
Catch ex as NilObjectException
  // nothing to do 
End Try

It’ll still break in the debugger, but it will no longer crash your app.