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

VulpesRank #55 · 29.2K reputationPosted Jan 5, 2012, 11:42 PM EST
Nafihudheen KT34 reputationPosted Jan 6, 2012, 5:52 PM EST
VulpesRank #55 · 29.2K reputationPosted Jan 7, 2012, 2:55 AM EST
Nafihudheen KT34 reputationPosted Jan 8, 2012, 6:53 PM EST
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
VulpesRank #55 · 29.2K reputationPosted Jan 8, 2012, 11:34 PM EST
Nafihudheen KT34 reputationPosted Jan 9, 2012, 1:17 AM EST