Question BackGround Printing

Tom

Well-known member
Joined
Aug 23, 2005
Messages
746
Programming Experience
5-10
I have a process that gets specified criteria, fills a dataset, and passes the dataset to a sub that prints a crystal report directly to the printer. Filling the dataset takes only milliseconds but printing the report takes a few seconds, I would like to do the printing in a background thread so I can continue onto the next record without waiting for it to complete.

Get criteria
Fill DataSet
Print Report
Clear Dataset
Start Over

My problem is when I attempt to use a background worker; it continues on past the print report process and clears the dataset. The background sub then throws an error due to the empty dataset. I have tried several different options including dataset.copy into a new dataset but continue to get the same results.

Can anyone provide some suggestions/examples or a better way of handling this?
 
But what good what that do, I would be forced to wait until it completes then before I can start my next fill
 
Ok I found a work-a-round. Instead of trying to pass the source or copied dataset to the background worker, I first set it to the datasource of the report. The report retained the data even if the source dataset gets cleared/disposed of during the process.

I each record being processed it will be printing one of several reports. Should I use the one background worker with a select case statement for all report printing or is a seperate worker needed for each report?
 
Over the weekend I was connected remotely to my work PC and what I thought was resolved actually is not. I came into the office this morning only to find a bunch of blank reports had printed. So setting the dataset to the report, load the report, sending to a background worker that only has one line of code which is to send report to printer didnt actually work. Again the source dataset is being cleared by the main thread before the background thread completes, which is sort of what I need but the report needs to print the record also. Any suggestions?
 
suggestions?

Forget Crystal, and write it yourself using PrintDocuments, BackgroundWorker and a Queue ?
 
Crystal is not the problem, the report doesnt even connect to a database, it connects only to the filled dataset that I assign it. This part works fine.

The problem i'm having is I would like to pass off the printing to a background thread but as soon as I do the main thread clears the dataset which the report then loses.
 
Back
Top