473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Displaying status to a window

L

In my application I am printing files to AdobePrinter. While I loop
through the files and print, I want to display the status to a window (
Ex: Printing to file file1.eps ). How can I do this? Can someone help
me with some sample code.

Thanks
L

Nov 16 '05 #1
6 1398
Try runing the task in a separate worker thread and update the text on the
label from the worker thread using a thread safe update. The main thread
should process the Paint and update the thread text,

- Shuvro

"L" <la********@investors.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

In my application I am printing files to AdobePrinter. While I loop
through the files and print, I want to display the status to a window (
Ex: Printing to file file1.eps ). How can I do this? Can someone help
me with some sample code.

Thanks
L

Nov 16 '05 #2
L
I am trying to program as below which is not working. The label on the
form is not being updated. Can somebody advice what is wrong with the
code

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;

namespace WindowsApplication5
{
public class MyClass
{
string fileName;
readonly object stateLock = new object();

int indexStat = 0;
Form2 Frm;
public MyClass()
{
}

public void ReportStatus()
{
for (indexStat = 0; indexStat <= 100; indexStat++)
{
lock(stateLock)
{
Frm.UpdateFormLabel(indexStat.ToString());
}
Thread.Sleep(100);
}
}

[STAThread]
static void Main(string[] args)
{
MyClass Class1 = new MyClass();
Class1.fileName = args[0];

Class1.Frm = new Form2();
Class1.Frm.Show();
ThreadStart statusStart = new ThreadStart(Class1.ReportStatus);
Thread statusThread = new Thread(statusStart);
statusThread.Name = "Status";
statusThread.Start();
}
}

public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.ComponentModel.Container components = null;

public Form2()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

public void UpdateFormLabel(string Msg)
{
label1.Text = Msg;
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(472, 128);
this.label1.TabIndex = 0;
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(488, 141);
this.Controls.Add(this.label1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);

}
#endregion
}
}

Nov 16 '05 #3
L
The code I pasted above is a prototype of my requirement. I do not have
enough knowledge of handling threads with forms. Any corrections or
suggestions will be appreciated.

Thanks
L

Nov 16 '05 #4
L

Nov 16 '05 #5
Hi,
Hope the link would give you some help.
http://www.codeproject.com/csharp/workerthread.asp

"L" <la********@investors.com>
??????:11**********************@z14g2000cwz.google groups.com...

In my application I am printing files to AdobePrinter. While I loop
through the files and print, I want to display the status to a window (
Ex: Printing to file file1.eps ). How can I do this? Can someone help
me with some sample code.

Thanks
L

Nov 16 '05 #6
L
Cant this be done with out using delegates and just using threads?
Thanks,
L

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeanne | last post by:
I am working on a cgi script that is suppose to pop-up a javascript box from the following perl variables:$TodayDate, $LinkCity, $LinkState. I recently encountered a problem with the $LinkCity...
0
by: Wynter | last post by:
RE: from Displaying a Document using the ASPNET user account to the Client Browser discussion (3/2/2004 Buddy Thanks for helping me on getting the document to display. But now I am left with a...
0
by: Earl Teigrob | last post by:
I can create a new custom control (and not change it) and add it to the toolbox and drag it onto the disign screen and it works just fine, displaying the text . However, when I add the following...
3
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - I have window.status="Moomin"; why doesn't the statusbar change?...
18
by: mistral | last post by:
Is there some other (more advanced) effects for status bar, other than standard Scroller Bar, TypeWriter Scroller, Flashing Bar, Decrypter, Ticker, World Clock?
4
by: =?Utf-8?B?YXVsZGg=?= | last post by:
hello, i'm not sure if this is possible. i have a small VS 2005 C# windows application. it has a textbox and a button. once the user presses the button it fires off many tasks. i want to use the...
7
by: hsegoy1979 | last post by:
Dear All Iam using file upload control and i want to display image in another pop up page .But image is not displaying in image control iam sending image path thru querystring . here is my code ...
9
by: LayneMitch via WebmasterKB.com | last post by:
Hello. Got another one for you folks. I'm working on this problem that wants me to 1. Prompt for name 2. Use pop-up box with name 3. Display current date on page in format "October 30, 2000."...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.