AcManager.Tools.Starters.ModuleStarter.GetDataAsync C# (CSharp) Method

GetDataAsync() private method

private GetDataAsync ( [ data, CancellationToken cancellation = default(CancellationToken) ) : Task
data [
cancellation System.Threading.CancellationToken
return Task
        public static async Task<string> GetDataAsync([Localizable(false),NotNull] string data, CancellationToken cancellation = default(CancellationToken)) {
            if (!IsAssettoCorsaRunning) {
                TryToRunAssettoCorsa();
                throw new InformativeException("Running AssettoCorsa.exe is required", "You’re using Module Starter, it works only though original launcher.");
            }

            var backdoor = BackdoorFilename;
            if (!File.Exists(backdoor)) {
                throw new InformativeException("Connection file is missing", "Make sure UI module is working properly.");
            }

            IniFile.Write(backdoor, "COMMAND", "CURRENT", JsonConvert.SerializeObject(new {
                name = data
            }).ToBase64());
            await Task.Delay(2000, cancellation);

            var ini = new IniFile(backdoor);
            var result = ini["RESULT"].GetNonEmpty(data.ToUpperInvariant());
            if (ini["COMMAND"].GetNonEmpty("CURRENT") != null || result == null) {
                throw new InformativeException("UI module does not respond", "Make sure UI module is working properly.");
            }
            
            return Convert.FromBase64String(result).ToUtf8String();
        }