Results 1 to 3 of 3

Thread: Timer callback

  1. #1

    Thread Starter
    Addicted Member DJ_Catboy's Avatar
    Join Date
    Jan 2003
    Location
    Suffolk, UK
    Posts
    159

    Timer callback

    Hi,

    I have a form and have created a timer. I want my timer to watch a print queue (look for changes every 5 seconds or whatever) and then update a listview on the main form. The problem is I can't think of a way to make the timer inform the form that something has happened - or another way I have tried to tackle it is to pass the object reference of the listview into the timer routine...... anybody got any examples/ideas?

    Regards,
    DJ

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    Okay. I have a question. Where is the timer created and where is the form created? I am assuming they are on diffirent forms or something.

    There are several answers.
    1) Create a public wrapper for the listbox.Items.Add() in the form that contains it(optional but creates less typing) and pass a refreance of the form to where ever. I usualy do that with a constructor.

    2) impliment the VB6 Forms Collection I posted in this forum. it will solve that problem quickly with only two changes to you code. Add an Ex to you Form
    Code:
    public class myForm : System.Windows.Forms.FormEx
    inheritance statement and construct your form using a key
    Code:
    myForm frm = new myForm("myForm1");
    .

    and finally
    Code:
    System.Windows.Forms.FormEx.Forms["myForm1"].ListAdd(QueeItem);
    3)put the timer on the form with the listbox and do this.listboxname.Items.Add(QueeItem);

    4)I dunno somebody provide 4
    Magiaus

    If I helped give me some points.

  3. #3
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256

    Re: Timer callback

    Originally posted by DJ_Catboy
    Hi,

    I have a form and have created a timer. I want my timer to watch a print queue (look for changes every 5 seconds or whatever) and then update a listview on the main form. The problem is I can't think of a way to make the timer inform the form that something has happened - or another way I have tried to tackle it is to pass the object reference of the listview into the timer routine...... anybody got any examples/ideas?

    Regards,
    DJ
    You might want to take a look at this http://msdn.microsoft.com/msdnmag/is...T/default.aspx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width