Hi folks,

In my c# epos app, i have a method which does two things:

It calls a method to update the Form with the change to be given to the customer.

It then calls a method to print the receipt to the serial printer.

Even though the update Form method is called first, it doesn't get enough time to update the label for the change (Other labels appear half-updated). THe Form just seems to not update until the printing it over.

I have tried adding Thread.Sleep(10) to the method which does the printing but all this does is just delay the receipt printing....

Any ideas?

Thanks

hmm ok, as it turns out, i don't think its the serial port writing causing this. I forgot to mention that after the printing method is called, a few other methods are called to stores stuff to a Sqlite database (which is slow). I think it is this that's causing the problem.

Really, what I am looking for is just some tips on how to make sure that the Form is updated before all the rest happens.

Apperently just calling the method first doesn't do this :(

Cheers

A method should only do one thing.

You could consider using a background worker thread, but its not really needed for something like this, call This.Refresh(); to refresh the controls on the form, that should do it, but if your methods use loops, try calling Application.DoEvents(); in the lengthy loop it will allow your form to process win messages sent to the application and allow it to paint as well.

use multithreading and asyncronous callback stuff.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.