All pastes #10695 Raw Edit

Stuff

public text v1 · immutable
#10695 ·published 2005-05-01 02:05 UTC
rendered paste body
using System;
using Gtk;
using System.Threading;


public class MyWindow : Window {
	
	public ProgressBar p ;
	
	public MyWindow () : base ("MyWindow")
	{
		SetDefaultSize (200, 10);

		
		p = new ProgressBar();
		
		VBox vb = new VBox();
		
		Button b1 = new Button("Start");
		Button b2 = new Button("Loop");
		b1.Clicked += Start;
		b2.Clicked += Loop;
		
		vb.PackStart(b1);
		vb.PackStart(b2);
		vb.PackStart(p);
		
		Add(vb);
		ShowAll ();
	
			
		
	}
	
	
	public void Threadwork(){
		while (true){
			p.Pulse();				
			while (Application.EventsPending ())
						Application.RunIteration ();
			Thread.Sleep(100);	
		}
	}

	void Loop(object o, EventArgs a){
		while (true) { //Do some job!}
	}
	void Start(object o, EventArgs a){
		Thread th = new Thread ( new ThreadStart(Threadwork) );
		th.Start();
		Console.WriteLine("Hey, new thread launched!");
	}
	

}