Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Load content on background thread

$
0
0

@monobeginner wrote:

Hello,

I have some question about loading content on background thread. Lets start with a piece of code:

        protected override void LoadContent()
        {
...
            SceneManager.LoadScenesContent(Content);
            Thread t = new Thread(() => LoadContentOnBackgroundThread()) { IsBackground = true, Name = "LoadContentThread" };
        t.Start();
        t.Join();
    }


    private void LoadContentOnBackgroundThread()
    {
        AudioManager.LoadContent(Content);
    }

I try to load assets like textures / fonts on main thread but audio on background thread. It works fine. When I move loading of textures / fonts also into background thread it stops working. I mean like debugger stops on loading some texture from content manager. How to load content on background thread properly ? I really have no idea what causes this issue, looks like content manager stucks on loading of texture, so maybe it is locked somehow ?

Offtopic: I really need loading of content on background thread because on Android, during splash screen, I have black screen instead of my splash graphic (reproduce rate about 50%). So sometimes it works fine, sometimes I have black screen.

I set up my splash screen "regular" way, just with style:

<style name="Theme.Splash" parent="android:Theme">
    <item name="android:windowBackground">@drawable/splash_background</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
  </style>

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles