My winforms application is receiving a file from SQL Server, and I would like to display how much of the file has been downloaded in the form of a progress bar.
To retrieve the file, I am calling a stored procedure and saving the result into a byte array with:
Dim file() as Byte = SQLCommand.ExecuteScalar()
This works fine and for smaller files, I don't really need a progress bar as they complete so quickly. However, some of the files may get quite large, and some of the connections might not be very good, so I really think I will need some sort of progress indication.
I understand that I will probably need to use a background worker thread, and I understand how to do that. But how can periodically check how much of the file has been received, as doing it the way I am, it seems to perform the action in one big chunk?
Can it be done this way? Or do I need to review how I am receiving the file entirely?
My application is VB.Net but C# answers would perfectly acceptable.