Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Simple syncronization test written by sp.
Browse files Browse the repository at this point in the history
svn path=/trunk/winforms/; revision=55461
  • Loading branch information
Jackson Harper committed Jan 12, 2006
1 parent 48ec5bb commit b183220
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
10 changes: 10 additions & 0 deletions timers/Makefile
@@ -0,0 +1,10 @@
all: mono

mono: swf-timers.cs
mcs swf-timers.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll

dotnet: swf-timers.cs
csc swf-timers.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll

clean:
rm swf-timers.exe -r -f
43 changes: 43 additions & 0 deletions timers/swf-timers.cs
@@ -0,0 +1,43 @@

using System;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Timers;
using System.Windows.Forms;

class Program {

static void ShowStackTrace (object o, ElapsedEventArgs e)
{
Console.WriteLine (counter);
Console.WriteLine ("Threads Equal: {0}", System.Threading.Thread.CurrentThread == startup_thread);
if (counter++ > 5) {
t.AutoReset = false;
t.Enabled = false;
}
}

static System.Threading.Thread startup_thread;
static System.Timers.Timer t;
static int counter = 0;

static void Main (string[] args)
{
bool so = (args.Length > 0);
Label label = new Label ();

Console.WriteLine ("STARTUP THREAD: " + System.Threading.Thread.CurrentThread.GetHashCode ());
startup_thread = System.Threading.Thread.CurrentThread;

t = new System.Timers.Timer (500);
if (so)
t.SynchronizingObject = label;
t.Elapsed += new ElapsedEventHandler (ShowStackTrace);
t.AutoReset = true;
t.Enabled = true;

System.Threading.Thread.Sleep (5000);
}
}

0 comments on commit b183220

Please sign in to comment.