Hai,
I want to do the printing from my dot net project as background work as a thread, for that what I did is, first collect the each output string to a collection of string
like this
myOutputStringCollection.Add(str);
then after collecting all lines I want to send it to printer, I write code like this which executes a thread
public static void printAllLines()
{
Thread t = new Thread(sendToPrinter);
t.Start();//starts the thread
}
and the send to printer function is like this
public static void sendToPrinter()
{
int count = myOutputStringCollection.Count;
string[] myArray = new string[count];
myOutputStringCollection.CopyTo(myArray, 0);
for (int i = 0; i < count; i++)
{
SendStringToPrinter(myArray[i].ToString());
}
Array.Clear(myArray, 0, myArray.Length);
}
but the problem here am facing is, if I click the print button more than one times Immediately then the printing alignment is not correct, I think if I handle the thread execution properly then it will be all right, If any body know more about threading and its operation then pls share here
Thanks in advance.
Loading
VulpesPosted Jan 6, 2012, 4:42 AM
Nafihudheen KTPosted Jan 9, 2012, 6:17 AM
VulpesPosted Jan 9, 2012, 4:34 AM
Nafihudheen KTPosted Jan 8, 2012, 11:53 PM
Thanks again Vulpes, its really help me but I can not code this
'this.Invoke' can not create in my class file, what is the solution any suggesion
VulpesPosted Jan 7, 2012, 7:55 AM
Nafihudheen KTPosted Jan 6, 2012, 10:52 PM