[Last Call] Learn how to a build a cloud-first strategyRegister Now


Adding a timer to the code

Posted on 2006-04-17
Medium Priority
Last Modified: 2010-04-16
I have the following code below which is part of the code I am using which interprets an image field in a database which contains binary data and outputs it in a folder on a directory in rtf format.

The folder can contain up to 10 to 30 different documents a day.

The code below opens up the documents in word and prints them out

object oMissing = System.Reflection.Missing.Value;
object oFalse = false;
object oTrue = true;
//create word
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oWord.ActivePrinter = @"\\printer name";

object file = Filename;
oDoc = oWord.Documents.Add(ref file, ref oMissing, ref oMissing, ref oMissing);

//print it
object xcopies = 1;
oDoc.PrintOut(ref oFalse, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref xcopies, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing);
oWord.Quit(ref oFalse, ref oMissing, ref oMissing);

I want to add a timer to this, but I am not sure how to do it and whereabouts in the code it should be placed. The timer should work as follows, one docmunets is printed out and instead of instantly opening up and printing the next document add a 30 second delay before printing and do this for every document contained in the folder.

Can anybody help

Question by:polynominal
  • 2
  • 2
LVL 48

Expert Comment

ID: 16475374

This line delays current thread for 30 seconds.

Author Comment

ID: 16476338
Thanks I get the error message Type or namespace thread could not be found

Expert Comment

ID: 16476561
Add - using System.Threading - on the top.
Whenever you get this "Type or namespace thread could not be found" error, search for the class name in msdn and see what namespace is required for that class.
here you can see System.Threading is required for Thread class.

Author Comment

ID: 16495440
Thanks for the answers. unfortunately msdn library is blocked at work so I cant see it
LVL 48

Accepted Solution

AlexFM earned 1000 total points
ID: 16495663

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question