зеркало из
1
0
Форкнуть 0

Add thread test case that fails right now

This commit is contained in:
Alp Toker 2006-12-06 00:50:08 +00:00
Родитель 6ebc30f1d1
Коммит d70db0e715
2 изменённых файлов: 73 добавлений и 0 удалений

Просмотреть файл

@ -25,6 +25,11 @@ test-ui.exe: PKGS = gtk-sharp-2.0
test-ui.exe: NDesk.DBus.dll NDesk.DBus.GLib.dll TestUI.cs
test-threads.exe: PKGS = gtk-sharp-2.0
test-threads.exe: NDesk.DBus.dll NDesk.DBus.GLib.dll TestThreads.cs
run:
echo '#!/bin/sh' > $@
echo 'export MONO_PATH=$(DBUS_SHARP_GLIB_PREFIX)/glib:$(DBUS_SHARP_PREFIX)/src:$$MONO_PATH' >> $@

68
examples/TestThreads.cs Normal file
Просмотреть файл

@ -0,0 +1,68 @@
// Copyright 2006 Alp Toker <alp@atoker.com>
// This software is made available under the MIT License
// See COPYING for details
using System;
//using ST = System.Threading;
using System.Threading;
using Gtk;
using NDesk.DBus;
using org.freedesktop.DBus;
public class TestThreads
{
public static void OnClick (object o, EventArgs args)
{
foreach (string n in bus.ListNames ()) {
TextIter endIter = tv.Buffer.EndIter;
tv.Buffer.Insert (ref endIter, n + '\n');
}
}
public static void Task ()
{
Console.WriteLine (bus.ListNames ());
}
public static void OnClickQuit (object o, EventArgs args)
{
//Application.Quit ();
Thread t = new Thread (Task);
t.Start ();
}
static TextView tv;
static IBus bus;
public static void Main ()
{
BusG.Init ();
Application.Init ();
tv = new TextView ();
ScrolledWindow sw = new ScrolledWindow ();
sw.Add (tv);
Button btn = new Button ("Click me");
btn.Clicked += OnClick;
Button btnq = new Button ("Click me (thread)");
btnq.Clicked += OnClickQuit;
VBox vb = new VBox (false, 2);
vb.PackStart (sw, true, true, 0);
vb.PackStart (btn, false, true, 0);
vb.PackStart (btnq, false, true, 0);
Window win = new Window ("D-Bus#");
win.SetDefaultSize (640, 480);
win.Add (vb);
win.Destroyed += delegate {Application.Quit ();};
win.ShowAll ();
bus = Bus.Session.GetObject<IBus> ("org.freedesktop.DBus", new ObjectPath ("/org/freedesktop/DBus"));
Application.Run ();
}
}