1
DotNet / Async corrupts Font ?
« on: July 24, 2018, 10:19:41 am »
(Using: SFML.NET 2.3)
I'm writing a resource loading screen. And I successfully implemented loading with async/await.
Next step is to display the progression. This is done with SFML.Text.
When starting the async, somehow the Font gets corrupted once. The outcome are missing letters in the Font data. The Font is NOT touched in the async chain!
If I recreate the Font after the async has fired its Tasking, everything seems to be fine.
There are not multiple Tasks in parallel, but only one at a time.
To me, this looks like the .net threading takes memory that is used by the Font?
I do not claim to have a deep understanding of what is happening here.
Here is my code in very reduced form. I test loading with a lot of 5MB bmps currently.
I'm glad if you guys have some ideas on SFML objects and threading. Are they safe
I'm writing a resource loading screen. And I successfully implemented loading with async/await.
Next step is to display the progression. This is done with SFML.Text.
When starting the async, somehow the Font gets corrupted once. The outcome are missing letters in the Font data. The Font is NOT touched in the async chain!
If I recreate the Font after the async has fired its Tasking, everything seems to be fine.
There are not multiple Tasks in parallel, but only one at a time.
To me, this looks like the .net threading takes memory that is used by the Font?
I do not claim to have a deep understanding of what is happening here.
Here is my code in very reduced form. I test loading with a lot of 5MB bmps currently.
I'm glad if you guys have some ideas on SFML objects and threading. Are they safe
Font font;
Text text;
ctor(){
font = new Font(); //path
text = new Text();
LoadResourcesAsync();
}
async void LoadResourcesAsync() {
await Load();
}
async Task Load(){
foreach
await Task.Run(() => ); //load stuff and report progress via event
}
void Draw(RenderTarget target) {
text.DisplayedString = currentFile; // or percentage (currentFile is updated via event)
target.Draw(text);
}
Text text;
ctor(){
font = new Font(); //path
text = new Text();
LoadResourcesAsync();
}
async void LoadResourcesAsync() {
await Load();
}
async Task Load(){
foreach
await Task.Run(() => ); //load stuff and report progress via event
}
void Draw(RenderTarget target) {
text.DisplayedString = currentFile; // or percentage (currentFile is updated via event)
target.Draw(text);
}