Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / July 2007

Tip: Looking for answers? Try searching our database.

Waiting for a process to Finish (Threading)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dean Richardson - 23 Jul 2007 11:29 GMT
Hello,

I have having issues with threading. Below is the code I am running:

'Prints the word doc
myWordApp.ActivePrinter = cboPrintList.SelectedItem

myWordApp.PrintOut()

'Sets the default printer back
myWordApp.ActivePrinter = strDefaultPrinter

'Pauses until the word document is printed
System.Threading.Thread.Sleep(2000)

'Closes the word document
myWordApp.Quit(False)

The issue is that the word document is still printing in word as the
Word Application closes, so the document never prints.

Is there a way to have quit word once the printing has finished by
using threads. I am quite new to threading, so I'm probably missing
something obvious (or not).

Many Thanks in Advance,
Dean
rowe_newsgroups - 23 Jul 2007 11:43 GMT
On Jul 23, 6:29 am, Dean Richardson <advertis...@deanrichardson.com>
wrote:
> Hello,
>
[quoted text clipped - 23 lines]
> Many Thanks in Advance,
> Dean

I don't think Threading will solve the problem, as the thread will not
know when printing has finished - which is what the problem seems to
be. It might be possible to start a new thread to do the work, set
IsBackground = False and give it a much larger Sleep timeout that will
always account for the document being spooled before the thread exits.

Also, I not sure if the Office PIA's available from Microsoft have the
capabilities to better monitor print capabilities in Word or not - but
it may be worth checking out.

Thanks,

Seth Rowe
Dean Richardson - 24 Jul 2007 17:25 GMT
> On Jul 23, 6:29 am, Dean Richardson <advertis...@deanrichardson.com>
> wrote:
[quoted text clipped - 42 lines]
>
> - Show quoted text -

Thanks for that. I ended up having a sleep method setup so that it
waits for 5000 milliseconds before running any further and its done
the job.

Thanks again,
Dean
mapi-user - 25 Jul 2007 23:16 GMT
Would this not work for you?

        Do While myWordApp.BackgroundPrintingStatus
            System.Windows.Forms.Application.DoEvents()
        Loop

> > On Jul 23, 6:29 am, Dean Richardson <advertis...@deanrichardson.com>
> > wrote:
[quoted text clipped - 49 lines]
> Thanks again,
> Dean

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.