Exemple #1
0
            public PoolWorker(DedicatedThreadPool pool, int workerId)
            {
                _pool       = pool;
                _threadExit = new TaskCompletionSource <object>();

                var thread = new Thread(RunThread, pool.Settings.ThreadMaxStackSize);

                thread.IsBackground = pool.Settings.ThreadType == ThreadType.Background;

                if (pool.Settings.Name != null)
                {
                    thread.Name = string.Format("{0}_{1}", pool.Settings.Name, workerId);
                }

                if (pool.Settings.ApartmentState != ApartmentState.Unknown)
                {
                    thread.SetApartmentState(pool.Settings.ApartmentState);
                }

                thread.Start();
            }
Exemple #2
0
        public Alex(LaunchSettings launchSettings)
        {
            EntityProperty.Factory = new AlexPropertyFactory();

            Instance        = this;
            LaunchSettings  = launchSettings;
            OperatingSystem = $"{System.Runtime.InteropServices.RuntimeInformation.OSDescription} ({System.Runtime.InteropServices.RuntimeInformation.OSArchitecture})";

            DeviceManager = new GraphicsDeviceManager(this)
            {
                PreferMultiSampling            = false,
                SynchronizeWithVerticalRetrace = false,
                GraphicsProfile = GraphicsProfile.Reach,
            };

            DeviceManager.PreparingDeviceSettings += (sender, args) =>
            {
                Gpu = args.GraphicsDeviceInformation.Adapter.Description;
                args.GraphicsDeviceInformation.PresentationParameters.DepthStencilFormat = DepthFormat.Depth24Stencil8;
                DeviceManager.PreferMultiSampling = true;
            };

            Content = new StreamingContentManager(base.Services, "assets");
            //	Content.RootDirectory = "assets";

            IsFixedTimeStep = false;
            // graphics.ToggleFullScreen();

            this.Window.AllowUserResizing  = true;
            this.Window.ClientSizeChanged += (sender, args) =>
            {
                if (DeviceManager.PreferredBackBufferWidth != Window.ClientBounds.Width ||
                    DeviceManager.PreferredBackBufferHeight != Window.ClientBounds.Height)
                {
                    if (DeviceManager.IsFullScreen)
                    {
                        DeviceManager.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                        DeviceManager.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                    }
                    else
                    {
                        DeviceManager.PreferredBackBufferWidth  = Window.ClientBounds.Width;
                        DeviceManager.PreferredBackBufferHeight = Window.ClientBounds.Height;
                    }

                    DeviceManager.ApplyChanges();

                    //CefWindow.Size = new System.Drawing.Size(Window.ClientBounds.Width, Window.ClientBounds.Height);
                }
            };


            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                Converters = new List <JsonConverter>()
                {
                    new Texture2DJsonConverter(GraphicsDevice)
                },
                Formatting = Formatting.Indented
            };

            ServerTypeManager = new ServerTypeManager();
            PluginManager     = new PluginManager();

            Storage = new StorageSystem(LaunchSettings.WorkDir);
            Options = new OptionsProvider(Storage);

            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <Alex>(this);
            serviceCollection.AddSingleton <ContentManager>(Content);
            serviceCollection.AddSingleton <IStorageSystem>(Storage);
            serviceCollection.AddSingleton <IOptionsProvider>(Options);

            InitiatePluginSystem(serviceCollection);

            ConfigureServices(serviceCollection);

            Services = serviceCollection.BuildServiceProvider();

            PluginManager.Setup(Services);

            PluginManager.LoadPlugins();

            ServerTypeManager.TryRegister("java", new JavaServerType(this));
            ServerTypeManager.TryRegister("bedrock", new BedrockServerType(this, Services.GetService <XboxAuthService>()));

            UIThreadQueue = new ConcurrentQueue <Action>();

            FpsMonitor = new FpsMonitor();

            Resources = Services.GetRequiredService <ResourceManager>();

            ThreadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount,
                                                                                 ThreadType.Background, "Dedicated ThreadPool"));

            KeyboardInputListener.InstanceCreated += KeyboardInputCreated;
        }
Exemple #3
0
 public DedicatedThreadPoolTaskScheduler(DedicatedThreadPool pool)
 {
     _pool = pool;
 }