public void Dispose()
        {
            if (client != null)
            {
                if (hPipe != 0)
                {
                    if (hUser != 0)
                    {
                        client.ReleaseUser(hPipe, hUser);
                        hUser = 0;
                    }

                    client.BReleaseSteamPipe(hPipe);
                    hPipe = 0;
                }

                if (!client.BShutdownIfAllPipesClosed())
                {
                    Console.WriteLine("BShutdownIfAllPipesClosed returned false");
                }

                client.Dispose();
                client = null;
            }

            if (user != null)
            {
                user.Dispose();
                user = null;
            }

            if (utils != null)
            {
                utils.Dispose();
                utils = null;
            }

            if (networking != null)
            {
                networking.Dispose();
                networking = null;
            }

            if (gameServerStats != null)
            {
                gameServerStats.Dispose();
                gameServerStats = null;
            }

            if (http != null)
            {
                http.Dispose();
                http = null;
            }

            if (inventory != null)
            {
                inventory.Dispose();
                inventory = null;
            }

            if (ugc != null)
            {
                ugc.Dispose();
                ugc = null;
            }

            if (apps != null)
            {
                apps.Dispose();
                apps = null;
            }

            if (gameServer != null)
            {
                //
                // Calling this can cause the process to hang
                //
                //gameServer.LogOff();

                gameServer.Dispose();
                gameServer = null;
            }

            if (friends != null)
            {
                friends.Dispose();
                friends = null;
            }

            if (servers != null)
            {
                servers.Dispose();
                servers = null;
            }

            if (userstats != null)
            {
                userstats.Dispose();
                userstats = null;
            }

            if (screenshots != null)
            {
                screenshots.Dispose();
                screenshots = null;
            }

            if (remoteStorage != null)
            {
                remoteStorage.Dispose();
                remoteStorage = null;
            }

            if (api != null)
            {
                if (isServer)
                {
                    api.SteamGameServer_Shutdown();
                }
                else
                {
                    api.SteamAPI_Shutdown();
                }

                api.Dispose();
                api = null;
            }
        }
Example #2
0
        public void Dispose()
        {
            if (user != null)
            {
                user.Dispose();
                user = null;
            }

            if (utils != null)
            {
                utils.Dispose();
                utils = null;
            }

            if (networking != null)
            {
                networking.Dispose();
                networking = null;
            }

            if (gameServerStats != null)
            {
                gameServerStats.Dispose();
                gameServerStats = null;
            }

            if (http != null)
            {
                http.Dispose();
                http = null;
            }

            if (inventory != null)
            {
                inventory.Dispose();
                inventory = null;
            }

            if (ugc != null)
            {
                ugc.Dispose();
                ugc = null;
            }

            if (apps != null)
            {
                apps.Dispose();
                apps = null;
            }

            if (gameServer != null)
            {
                gameServer.Dispose();
                gameServer = null;
            }

            if (friends != null)
            {
                friends.Dispose();
                friends = null;
            }

            if (servers != null)
            {
                servers.Dispose();
                servers = null;
            }

            if (userstats != null)
            {
                userstats.Dispose();
                userstats = null;
            }

            if (screenshots != null)
            {
                screenshots.Dispose();
                screenshots = null;
            }

            if (remoteStorage != null)
            {
                remoteStorage.Dispose();
                remoteStorage = null;
            }

            if (matchmaking != null)
            {
                matchmaking.Dispose();
                matchmaking = null;
            }

            if (applist != null)
            {
                applist.Dispose();
                applist = null;
            }

            if (client != null)
            {
                client.Dispose();
                client = null;
            }

            if (api != null)
            {
                if (isServer)
                {
                    api.SteamGameServer_Shutdown();
                }
                else
                {
                    api.SteamAPI_Shutdown();
                }

                //
                // The functions above destroy the pipeline handles
                // and all of the classes. Trying to call a steam function
                // at this point will result in a crash - because any
                // pointers we stored are not invalid.
                //

                api.Dispose();
                api = null;
            }
        }