2002-10-20 01:18:59 +02:00
|
|
|
// GLib.Source.cs - Source class implementation
|
|
|
|
//
|
|
|
|
// Author: Duncan Mak <duncan@ximian.com>
|
|
|
|
//
|
2004-06-25 20:42:19 +02:00
|
|
|
// Copyright (c) 2002 Mike Kestner
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of version 2 of the Lesser GNU General
|
|
|
|
// Public License as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this program; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
|
|
|
|
2002-10-20 01:18:59 +02:00
|
|
|
|
|
|
|
namespace GLib {
|
|
|
|
|
|
|
|
using System;
|
2004-09-20 18:43:16 +02:00
|
|
|
using System.Collections;
|
2002-10-20 01:18:59 +02:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
2007-10-24 22:13:08 +02:00
|
|
|
public delegate bool GSourceFunc ();
|
|
|
|
|
2004-09-20 18:43:16 +02:00
|
|
|
//
|
|
|
|
// Base class for IdleProxy and TimeoutProxy
|
|
|
|
//
|
|
|
|
internal class SourceProxy {
|
|
|
|
internal Delegate real_handler;
|
|
|
|
internal Delegate proxy_handler;
|
2008-02-21 17:32:03 +01:00
|
|
|
internal uint ID;
|
2004-09-20 18:43:16 +02:00
|
|
|
|
|
|
|
internal void Remove ()
|
|
|
|
{
|
2008-02-21 17:32:03 +01:00
|
|
|
lock (Source.source_handlers)
|
|
|
|
Source.source_handlers.Remove (ID);
|
2004-09-20 18:43:16 +02:00
|
|
|
real_handler = null;
|
|
|
|
proxy_handler = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-20 01:18:59 +02:00
|
|
|
public class Source {
|
2003-11-28 06:29:34 +01:00
|
|
|
private Source () {}
|
2002-10-20 01:18:59 +02:00
|
|
|
|
2004-09-20 18:43:16 +02:00
|
|
|
internal static Hashtable source_handlers = new Hashtable ();
|
|
|
|
|
2009-09-02 22:17:37 +02:00
|
|
|
[DllImport ("libglib-2.0-0.dll", CallingConvention = Global.CallingConvention)]
|
2002-10-20 01:18:59 +02:00
|
|
|
static extern bool g_source_remove (uint tag);
|
|
|
|
|
|
|
|
public static bool Remove (uint tag)
|
|
|
|
{
|
2005-02-28 19:11:24 +01:00
|
|
|
lock (Source.source_handlers)
|
|
|
|
source_handlers.Remove (tag);
|
2002-10-20 01:18:59 +02:00
|
|
|
return g_source_remove (tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|