Click here to Skip to main content
16,006,013 members
Home / Discussions / C#
   

C#

 
GeneralRe: convert time and minutes Pin
onetreeup21-Apr-09 9:21
onetreeup21-Apr-09 9:21 
AnswerRe: convert time and minutes Pin
Edwin Brunner21-Apr-09 9:23
Edwin Brunner21-Apr-09 9:23 
GeneralRe: convert time and minutes Pin
onetreeup21-Apr-09 9:36
onetreeup21-Apr-09 9:36 
GeneralRe: convert time and minutes Pin
Edwin Brunner21-Apr-09 9:50
Edwin Brunner21-Apr-09 9:50 
Questionhow to change property of form in an other started thread? Pin
Sajjad Izadi21-Apr-09 8:08
Sajjad Izadi21-Apr-09 8:08 
AnswerRe: how to change property of form in an other started thread? Pin
Henry Minute21-Apr-09 8:16
Henry Minute21-Apr-09 8:16 
GeneralRe: how to change property of form in an other started thread? [modified] Pin
Sajjad Izadi21-Apr-09 9:03
Sajjad Izadi21-Apr-09 9:03 
AnswerRe: how to change property of form in an other started thread? [modified] Pin
DaveyM6921-Apr-09 10:44
professionalDaveyM6921-Apr-09 10:44 
I've constructed a very simple sample using a System.Timers.Timer as it runs on a seperate thread. You should be able to figure it out from this.

[Edit] Changed the sample code to show how to call a method with parameters. [/Edit]
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        System.Timers.Timer timer;
        public Form1()
        {
            InitializeComponent();
            timer = new System.Timers.Timer();
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            timer.Start();
        }

        void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            /* System.InvalidOperationException "Cross-thread operation not valid..."
            will be thrown if you try to alter the property directly from a different thread */
            if (this.InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate() { UpdateText(sender, e); }));
            }
            else
            {
                UpdateText(sender, e);
            }
        }
        private void UpdateText(object sender, System.Timers.ElapsedEventArgs e)
        {
            Text = e.SignalTime.ToString();
        }
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus)

modified on Tuesday, April 21, 2009 4:50 PM

QuestionWhere to start? - Calculating the size of an object (square footage) in an image Pin
shultas21-Apr-09 8:06
shultas21-Apr-09 8:06 
AnswerRe: Where to start? - Calculating the size of an object (square footage) in an image Pin
Henry Minute21-Apr-09 8:19
Henry Minute21-Apr-09 8:19 
AnswerRe: Where to start? - Calculating the size of an object (square footage) in an image Pin
bulg21-Apr-09 12:11
bulg21-Apr-09 12:11 
QuestionEmbed PDF viewer in C# Windows App Pin
Engineer Joe21-Apr-09 7:24
Engineer Joe21-Apr-09 7:24 
QuestionReturn a function value after leaving the function and wait for corresponding event? Pin
rpm820021-Apr-09 5:05
rpm820021-Apr-09 5:05 
AnswerRe: Return a function value after leaving the function and wait for corresponding event? Pin
DaveyM6921-Apr-09 5:53
professionalDaveyM6921-Apr-09 5:53 
QuestionDeleting a node from Xml Pin
MehmetKocc21-Apr-09 4:49
MehmetKocc21-Apr-09 4:49 
AnswerRe: Deleting a node from Xml Pin
Christian Graus21-Apr-09 11:24
protectorChristian Graus21-Apr-09 11:24 
QuestionGet const-collection from code? Pin
Ariadne21-Apr-09 4:29
Ariadne21-Apr-09 4:29 
AnswerRe: Get const-collection from code? Pin
DaveyM6921-Apr-09 4:49
professionalDaveyM6921-Apr-09 4:49 
GeneralRe: Get const-collection from code? Pin
OriginalGriff21-Apr-09 4:54
mveOriginalGriff21-Apr-09 4:54 
GeneralRe: Get const-collection from code? Pin
Pete O'Hanlon21-Apr-09 4:57
mvePete O'Hanlon21-Apr-09 4:57 
GeneralRe: Get const-collection from code? Pin
OriginalGriff21-Apr-09 5:07
mveOriginalGriff21-Apr-09 5:07 
AnswerRe: Get const-collection from code? Pin
Pete O'Hanlon21-Apr-09 4:56
mvePete O'Hanlon21-Apr-09 4:56 
GeneralRe: Get const-collection from code? Pin
Ariadne22-Apr-09 2:02
Ariadne22-Apr-09 2:02 
AnswerRe: Get const-collection from code? Pin
Rolando CC21-Apr-09 5:30
professionalRolando CC21-Apr-09 5:30 
QuestionAccessing File from Remote PC Pin
satsumatable21-Apr-09 4:21
satsumatable21-Apr-09 4:21 

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.