BeardedManStudios.Network.Unity.MainThreadManager.Run C# (CSharp) Метод

Run() публичный статический Метод

Add a function to the list of functions to call on the main thread via the Update function
public static Run ( System.Action action ) : void
action System.Action The method that is to be run on the main thread
Результат void
		public static void Run(Action action)
		{
			// Only create this object on the main thread
#if NETFX_CORE
			if (ReferenceEquals(Instance, null))
#else
			if (ReferenceEquals(Instance, null) && Threading.ThreadManagement.IsMainThread)
#endif
			{
				Create();
			}

			// If we are in the loop and it is trying to add main thread actions, then add it to the
			// back buffer of actions to be added after the loop has been completed
			if (inLoop)
			{
				mainThreadActionsBuffer.Add(action);
				return;
			}

			// Make sure to lock the mutex so that we don't override
			// other threads actions
			lock (mutex)
			{
				mainThreadActions.Add(action);
			}
		}