How to avoid the White Blank Screen?

Using VB6

At the time of executing, it showing white blank screen while it was working with database, How to avoid the white blank screen in VB6.

WHITE BLANK SCREEN MEANS HANGING (WHEN IT WAS WORKING WITH DATABASE).

How to avoid that?

1 vb6
13.10.2009 15:31:05
This used to happen to me all the time. Then I learned how to optimize my database to make it faster. The problem has disappeared.
George Mastros 13.10.2009 15:42:20
Does this answer your question? How to exit the program immediately?
tabdiukov 25.12.2019 02:24:32
5 ОТВЕТОВ
РЕШЕНИЕ

I assume you mean that the GUI won't redraw itself when executing a long-running operation. (Shouldn't actually be that visible starting with Vista, but I digress).

If your long-running operation is composed of several steps or tight loops, then you can sprinkle a call to DoEvents every once in a while to cause the form to remain somewhat responsive even when doing work.

Another option would be to migrate your long-running work into a separate thread but last I looked this wasn't exactly trivial or easily possible in VB6.

4
13.10.2009 15:38:49
People always seem to overlook the simple methods when worrying about background processing on a separate thread in VB6. Gopal's talking about database operations - so just use ADO's native support for asynchronous processing. Alternatively, follow AngryHacker's answer and delegate the work to an ActiveX exe so it runs out-of-process in a separate thread. Both solutions get the job done with a minimum of fuss (and it's easier than classic multithreading in .NET IMHO).
MarkJ 14.10.2009 08:23:44

You should work with data base in separate thread, and any time-consuming operation should be run in a separate thread too. In this case your user interface won't be frozen.

1
13.10.2009 15:34:42
Not so easy. This is VB6 we are talking about.
AngryHacker 13.10.2009 17:40:06
What is no so easy? Threading approaches is the same on almost every platform.
Restuta 13.10.2009 21:44:19
No, it's not the same on every platform. VB6 doesn't support multiple threads in the same exe program.
MarkJ 14.10.2009 08:15:47
Pscode sample is a rip off of M. Curland's multi-threading samples.
wqw 14.10.2009 19:35:39

Your first instinct should be to put your resource-intensive operations in a separate thread. This is a bit difficult in VB6, although possible (but not recommended) if you invoke the native CreateThread API.

You can also migrate to VB.NET, and use Thread objects natively.

0
13.10.2009 15:38:34
There's many better ways than using CreateThread. Use ADO's native support for asynchronous operations, or delegate to an ActiveX exe as in AngryHacker's answer.
MarkJ 14.10.2009 08:20:08

This is actually the same problem as your "How to exit the program immediately" question. In both cases, the problem is that your database operation is blocking the VB6 program from executing.

  • The answer you accepted for the other question - use ADO to carry out the operations asynchronously - will also solve this blank screen problem.
  • Or if you prefer, follow one of my suggestions in my answer to your other question and use a .NET background worker component through Interop like this.
  • Or follow my other suggestion and delegate the database work to an ActiveX exe like this. EDIT AngryHacker's nice answer to this question uses this method.
1
23.05.2017 11:48:41

I posted this as an answer to another question, but the pattern applies here as well:

VB6, on its own, is single threaded. However, you can make it somewhat multithreaded via the use of ActiveX EXE that run in their own process, yet still are tethered to the original VB6-created EXE.

What I've used in the past is the Timer object in conjunction with an ActiveX EXE. This approach will give you an ability to localize all the downloading logic in one place, control it like you control a regular object and have it run in a separate EXE, thus by default making it multi-threaded.

So the way this works is like so:

You call the LongRunningOperation method on the ActiveX EXE object In the LongRunningOperation method, you instantiate the Timer and have it kick off almost immediately. You get out of the LongRunningOperation method, thus giving control back to the entity that called it. Then you communicate back to the main app via Events (e.g. LongRunningOperationProgress or LongRunningOperationComplete, etc...)

I recommend the Timer object from Karl Petersen.

1
13.10.2009 19:25:10
+1. I suggested this in my answer to Gopal's other question about background work in VB6. stackoverflow.com/questions/1264513/…
MarkJ 14.10.2009 08:16:50