diff --git a/src/GLib.IO.cs b/src/GLib.IO.cs
index e9601d9..1df22df 100644
--- a/src/GLib.IO.cs
+++ b/src/GLib.IO.cs
@@ -5,6 +5,7 @@
 using System;
 using System.Collections;
 using System.Runtime.InteropServices;
+using NDesk.DBus;
 
 namespace NDesk.GLib
 {
@@ -167,6 +168,49 @@ namespace NDesk.GLib
 		{
 			g_main_context_wakeup (context);
 		}
+
+		[DllImport(GLIB)]
+			static extern bool g_main_context_iteration (IntPtr context, bool may_block);
+
+		private static bool timerThreadException=false;
+		private static int timeoutReceivingData=500;
+
+		public int TimeoutReceivingData {
+			get {
+				return timeoutReceivingData;
+			}
+			set {
+				timeoutReceivingData=value;
+			}
+		}
+
+		private static void timerThread() {
+			// If timout value is not positive, the timeout handling is disabled.
+			if (timeoutReceivingData>0) {
+				System.Threading.Thread.Sleep(timeoutReceivingData);
+				System.Console.Out.WriteLine("Timer expired...");
+				timerThreadException=true;
+			}
+			return;
+		}
+
+		public static void MainContextIterator (IntPtr context, bool may_block, Connection conn)
+		{
+
+			System.Threading.Thread thread=new System.Threading.Thread(new System.Threading.ThreadStart(timerThread));
+			thread.IsBackground=true;
+			thread.Start();
+			BusG.readEvent=false;
+			while (!BusG.readEvent) {
+				g_main_context_iteration (context,may_block);
+				if (timerThreadException) {
+					throw new Exception("Timer Expired");
+				}
+			}
+			thread.Abort();
+			thread=null;
+		}
+
 	}
 
 	//From Mono.Unix and poll(2)
diff --git a/src/GLib.cs b/src/GLib.cs
index ccfdfc4..3e91a2d 100644
--- a/src/GLib.cs
+++ b/src/GLib.cs
@@ -6,6 +6,7 @@ using System;
 using NDesk.DBus;
 using NDesk.GLib;
 using org.freedesktop.DBus;
+using System.Runtime.InteropServices;
 
 namespace NDesk.DBus
 {
@@ -13,6 +14,9 @@ namespace NDesk.DBus
 	public static class BusG
 	{
 		static bool initialized = false;
+
+		public static bool readEvent=false;
+
 		public static void Init ()
 		{
 			if (initialized)
@@ -36,6 +40,8 @@ namespace NDesk.DBus
 					return false;
 				}
 
+				readEvent=true;
+
 				//this may not provide expected behaviour all the time, but works for now
 				conn.Iterate ();
 				return true;
@@ -48,6 +54,12 @@ namespace NDesk.DBus
 		{
 			IOChannel channel = new IOChannel ((int)conn.Transport.SocketHandle);
 			IO.AddWatch (channel, IOCondition.In | IOCondition.Hup, dispatchHandler);
+			conn.WaitForIOCompletitionFuncEvent += waitForData;
+		}
+
+		static public void waitForData(Connection conn) {
+			IO.MainContextIterator(System.IntPtr.Zero,true,conn);
 		}
+			
 	}
 }

