async private Task ApplyMetadata(Map map)
        {
            try
            {
                if (map == null)
                {
                    return;
                }

                FileInfo fi = new FileInfo(_mapServerService.Options.ServicesPath + @"/" + map.Name + ".meta");

                IEnumerable <IMapApplicationModule> modules = null;
                if (MapDocument is IMapDocumentModules)
                {
                    modules = ((IMapDocumentModules)MapDocument).GetMapModules(map);
                }

                IServiceMap sMap = await ServiceMap.CreateAsync(map, _mapServerService.Instance, modules);

                XmlStream xmlStream;
                // 1. Bestehende Metadaten auf sds anwenden
                if (fi.Exists)
                {
                    xmlStream = new XmlStream("");
                    xmlStream.ReadStream(fi.FullName);
                    sMap.ReadMetadata(xmlStream);
                }
                // 2. Metadaten neu schreiben...
                xmlStream = new XmlStream("Metadata");
                await sMap.WriteMetadata(xmlStream);

                if (map is Metadata)
                {
                    await map.SetMetadataProviders(await sMap.GetMetadataProviders(), map, true);

                    await map.UpdateMetadataProviders();
                }

                // Overriding: no good idea -> problem, if multiple instances do this -> killing the metadata file!!!
                //fi.Refresh();
                //if (!fi.Exists)
                //{
                //    xmlStream.WriteStream(fi.FullName);
                //}
            }
            catch (Exception ex)
            {
                _logger.LogError($"Map { map.Name }: ApplyMetadata - { ex.Message }");
            }
        }