Beispiel #1
0
        /// ------------------------------------------------------------------------------------
        private bool LoadFwDataForPa(PaRemoteRequest requestor, string name, string server,
                                     bool loadOnlyWs, int timeToWaitForLoadingData,
                                     bool newProcessStarted, out bool foundFwProcess)
        {
            foundFwProcess = false;

            Func <string, string, bool> invoker = requestor.ShouldWait;
            DateTime endTime = DateTime.Now.AddMilliseconds(timeToWaitForLoadingData);

            // Wait until this process knows which project it is loading.
            bool shouldWait;

            do
            {
                IAsyncResult ar = invoker.BeginInvoke(name, server, null, null);
                if (!ar.AsyncWaitHandle.WaitOne(endTime - DateTime.Now, false))
                {
                    return(false);
                }

                // Get the return value of the ShouldWait method.
                shouldWait = invoker.EndInvoke(ar);
                if (shouldWait)
                {
                    if (timeToWaitForLoadingData > 0 && DateTime.Now > endTime)
                    {
                        return(false);
                    }

                    Thread.Sleep(100);
                }
            } while (shouldWait);

            if (!requestor.IsMyProject(name, server))
            {
                return(false);
            }

            string xml = requestor.GetWritingSystems();

            m_writingSystems = XmlSerializationHelper.DeserializeFromString <List <PaWritingSystem> >(xml);

            if (!loadOnlyWs)
            {
                xml          = requestor.GetLexEntries();
                m_lexEntries = XmlSerializationHelper.DeserializeFromString <List <PaLexEntry> >(xml);
            }

            if (newProcessStarted)
            {
                requestor.ExitProcess();
            }

            foundFwProcess = true;
            return(true);
        }
Beispiel #2
0
		/// ------------------------------------------------------------------------------------
		private bool LoadFwDataForPa(PaRemoteRequest requestor, string name, string server,
			bool loadOnlyWs, int timeToWaitForLoadingData,
			bool newProcessStarted, out bool foundFwProcess)
		{
			foundFwProcess = false;

			Func<string, string, bool> invoker = requestor.ShouldWait;
			DateTime endTime = DateTime.Now.AddMilliseconds(timeToWaitForLoadingData);

			// Wait until this process knows which project it is loading.
			bool shouldWait;
			do
			{
				IAsyncResult ar = invoker.BeginInvoke(name, server, null, null);
				if (!ar.AsyncWaitHandle.WaitOne(endTime - DateTime.Now, false))
					return false;

				// Get the return value of the ShouldWait method.
				shouldWait = invoker.EndInvoke(ar);
				if (shouldWait)
				{
					if (timeToWaitForLoadingData > 0 && DateTime.Now > endTime)
						return false;

					Thread.Sleep(100);
				}
			} while (shouldWait);

			if (!requestor.IsMyProject(name, server))
				return false;

			string xml = requestor.GetWritingSystems();
			m_writingSystems = XmlSerializationHelper.DeserializeFromString<List<PaWritingSystem>>(xml);

			if (!loadOnlyWs)
			{
				xml = requestor.GetLexEntries();
				m_lexEntries = XmlSerializationHelper.DeserializeFromString<List<PaLexEntry>>(xml);
			}

			if (newProcessStarted)
				requestor.ExitProcess();

			foundFwProcess = true;
			return true;
		}