Mono.UIAutomation.UiaDbusSource.UiaDbusAutomationSource.FetchUiaDbusNames C# (CSharp) Method

FetchUiaDbusNames() private method

private FetchUiaDbusNames ( ) : void
return void
		private void FetchUiaDbusNames ()
		{
			var busNames = new List<string> ();

			IBus ibus = Bus.Session.GetObject<IBus> (DBusName,
			                                         new ObjectPath (DBusPath));
			// Look for buses that contain DCI.IApplication
			foreach (string busName in ibus.ListNames ()) {
				// Reading introspection data hangs on some buses
				// for unknown reasons, so we call Introspect
				// asynchronously.  Note that we are using
				// internal dbus-sharp classes.  The old
				// behavior was to spin off threads, but this
				// triggers a Mono bug on Fedora
				// (BNC#628639/632133)
				ObjectPath op = new ObjectPath (DC.Constants.ApplicationPath);
				MethodCall methodCall = new MethodCall (op,
					"org.freedesktop.DBus.Introspectable",
					"Introspect", busName, Signature.Empty);
				PendingCall pendingCall = Bus.Session.SendWithReply (methodCall.message);
				pendingCall.Completed +=  (message) => {
					MessageReader reader = new MessageReader (message);
					string data = reader.ReadString ();
					if (data.Contains (DC.Constants.ApplicationInterfaceName))
						busNames.Add ((string)message.Header [FieldCode.Sender]);
				};
			}
			Thread.Sleep (1000);

			lock (uiaDbusNamesLock)
				uiaDbusNames = busNames;
		}