Click here to Skip to main content
15,881,380 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sign Language Recognition Pin
RimaTeliani3-Jun-12 2:09
RimaTeliani3-Jun-12 2:09 
AnswerRe: Sign Language Recognition Pin
Richard MacCutchan3-Jun-12 0:53
mveRichard MacCutchan3-Jun-12 0:53 
GeneralRe: Sign Language Recognition Pin
RimaTeliani3-Jun-12 2:17
RimaTeliani3-Jun-12 2:17 
AnswerRe: Sign Language Recognition Pin
Eddy Vluggen3-Jun-12 2:55
professionalEddy Vluggen3-Jun-12 2:55 
GeneralRe: Sign Language Recognition Pin
RimaTeliani3-Jun-12 3:06
RimaTeliani3-Jun-12 3:06 
GeneralRe: Sign Language Recognition Pin
Eddy Vluggen3-Jun-12 4:38
professionalEddy Vluggen3-Jun-12 4:38 
GeneralRe: Sign Language Recognition Pin
RimaTeliani3-Jun-12 21:14
RimaTeliani3-Jun-12 21:14 
QuestionHow to sleep the thread in this example? Pin
daCrazyDude2-Jun-12 17:22
daCrazyDude2-Jun-12 17:22 
Hi,

I am writing an automated printer driver performance measuring tool. I have one problem that I need to fix.

Please check the sample code below.

What I need to do is, when I add the job to the print queue, I need to "poll" for the "isDeleted" status (or if possible, "isCompleted" status) and display the time (that part is not written in the sample code) it took to finish the job. In this case, "finish" means that the PRN file has been created. (The port of the printer is set to Local port: PRN file path.)

For this, I need to add a pause (of suitably low amount so that it doesn't affect the time) where I have put a comment in the code below.

I can easily do this with a timer, but it got a bit complicated when i kept on adding features. (i would be adding a list of job, would be backing up the PRN files, get time measurement, use two drivers and compare performance etc. etc.)

C#
using System;
using System.Windows.Forms;
using System.Printing;
using System.Threading;

namespace AddJob
{
    public partial class frmAddJob : Form
    {
        public frmAddJob()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread printingThread = new Thread(printXPS);
            printingThread.SetApartmentState(ApartmentState.STA);
            printingThread.Start();
        }

        private void printXPS()
        {
            LocalPrintServer lp = new LocalPrintServer();
            PrintQueue pq = LocalPrintServer.GetDefaultPrintQueue();                      

            try
            {
                PrintSystemJobInfo psji = pq.AddJob("myXPSJob", "C:\\test.xps", false);

                while (psji.IsDeleted != true)
                {                    
                    //need to wait here for some time

                    psji.Refresh();
                }

                MessageBox.Show("Done");
            }
            catch
            {
                MessageBox.Show("Error");
            }                        
        }
    }
}


Does anyone have any tips for me?
AnswerRe: How to sleep the thread in this example? Pin
Luc Pattyn3-Jun-12 4:57
sitebuilderLuc Pattyn3-Jun-12 4:57 
AnswerRe: How to sleep the thread in this example? Pin
daCrazyDude6-Jun-12 15:48
daCrazyDude6-Jun-12 15:48 
Questioncombine edits Pin
dcof2-Jun-12 16:27
dcof2-Jun-12 16:27 
AnswerRe: combine edits Pin
OriginalGriff3-Jun-12 0:27
mveOriginalGriff3-Jun-12 0:27 
GeneralRe: combine edits Pin
dcof3-Jun-12 18:04
dcof3-Jun-12 18:04 
AnswerRe: combine edits Pin
Paul Conrad4-Jun-12 6:38
professionalPaul Conrad4-Jun-12 6:38 
AnswerRe: combine edits Pin
Luc Pattyn3-Jun-12 4:58
sitebuilderLuc Pattyn3-Jun-12 4:58 
Questionbst Pin
negar parham2-Jun-12 7:02
negar parham2-Jun-12 7:02 
AnswerRe: bst Pin
Paul Conrad2-Jun-12 7:07
professionalPaul Conrad2-Jun-12 7:07 
AnswerRe: bst Pin
AmitGajjar4-Jun-12 2:11
professionalAmitGajjar4-Jun-12 2:11 
QuestionC# working with strings Pin
dcof2-Jun-12 6:48
dcof2-Jun-12 6:48 
AnswerRe: C# working with strings Pin
Paul Conrad2-Jun-12 7:02
professionalPaul Conrad2-Jun-12 7:02 
AnswerRe: C# working with strings Pin
OriginalGriff2-Jun-12 9:01
mveOriginalGriff2-Jun-12 9:01 
Questionsend SMS in C# Pin
sina rahimzadeh1-Jun-12 21:48
sina rahimzadeh1-Jun-12 21:48 
AnswerRe: send SMS in C# Pin
Richard MacCutchan1-Jun-12 22:32
mveRichard MacCutchan1-Jun-12 22:32 
AnswerRe: send SMS in C# Pin
Sander Rossel2-Jun-12 0:43
professionalSander Rossel2-Jun-12 0:43 
AnswerRe: send SMS in C# Pin
taha bahraminezhad Jooneghani3-Jun-12 1:56
taha bahraminezhad Jooneghani3-Jun-12 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.