StartCoroutine isn't working

Hey Guys
I got a problem I just have a script were the IEmumerator is not activated and I don’t know why. By the way is is the LoadUserDataCoroutine IEmumerator thats invoked in the Refresh and Start Methods, but only works in the Start-Methode. Can someone help me? here is the code:using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DentedPixel;
using UnityEngine.SceneManagement;
using Firebase.Database;
using Firebase;
using Firebase.Auth;
using Firebase.Analytics;
using UnityEngine.UI;

public class Bar : MonoBehaviour
{
public GameObject bar;
public int time;
private FirebaseAuthManager FirebaseAuthManager;
public FirebaseApp Appp;
public FirebaseAuth Authh;
public DatabaseReference DBreference = FirebaseDatabase.DefaultInstance.RootReference;
public FirebaseUser Userr;
public static float Points;
public Text Pointstext;
private bool continueLoadUserData = false;

void Start()
{
    FirebaseApp app = FirebaseApp.DefaultInstance;
    DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

    FirebaseAuthManager = FindObjectOfType<FirebaseAuthManager>();

    FirebaseAuthManager.app = Appp;
    FirebaseAuthManager.auth = Authh;
    FirebaseAuthManager.user = Userr;

    print("1");
    Test2();

    // Initialize DBreference
    DBreference = reference;

    Test3();
    StartCoroutine(LoadUserDataCoroutine());

    // Move the call to AnimateBar here
    Test1();
    AnimateBar();
}

public void Test1()
{
    print("Test1");
    Test();
}

public void Test2()
{
    print("Test2");
    Test();
}

public void Test3()
{
    print("Test3");
    Test();
}

public void Test4()
{
    print("Test4");
    if (FirebaseAuthManager.user == null)
    {
        print("user is null");
        return;
    }
    Test();
}

public void Test5()
{
    print("Test5");
    Test();
}

public void Test6()
{
    print("Test6");
    Test();
}

public void Test7()
{
    print("Test7");
    Test();
}

public void Test8()
{
    print("Test8");
    Test();
}

public void Test9()
{
    print("Test9");
    Test();
}

public void Test10()
{
    print("Test10");
    Test();
}

public void Test()
{
    if (DBreference == null)
    {
        print("Bammm");
    }

    if (FirebaseAuthManager.user == null)
    {
        print("user");
        return;
    }

    if (FirebaseAuthManager.auth == null)
    {
        print("auth");
        return;
    }

    if (FirebaseAuthManager.app == null)
    {
        print("app");
        return;
    }
}

public void AnimateBar()
{
    
    Test4();
    LeanTween.scaleX(bar, 1, time).setOnComplete(Refresh);
}

public void Refresh()
{
    
    LeanTween.scaleX(bar, 0, 0);
    Points += 0.05f;
    print("OK++++++++++");
    Test5();

    // Überprüfe, ob DBreference initialisiert wurde
    if (FirebaseAuthManager.DBreference != null)
    {
        // Aktualisiere Punkte in der Datenbank
        var DBTask = FirebaseAuthManager.DBreference.Child("users").Child(FirebaseAuthManager.auth.CurrentUser.UserId).Child("Points").SetValueAsync(Points);

        DBTask.ContinueWith(task =>
        {
            if (task.Exception != null)
            {
                //Debug.LogWarning($"Fehler beim Aktualisieren der Punkte in der Datenbank: {task.Exception}");
            }
            else if (task.Exception == null)
            {
                Debug.Log("Punkte wurden erfolgreich aktualisiert");

                LoadUserDataCoroutine();
                StartCoroutine(LoadUserDataCoroutine());
                this.StartCoroutine(this.LoadUserDataCoroutine());

                return;
            }

        });
    }
    else
    {
        Debug.LogWarning("DBreference ist null, Punkte wurden nicht in der Datenbank aktualisiert");
        return;
    }
    
}

private IEnumerator LoadUserDataCoroutine()
{

    yield return new WaitForSeconds(1f);
    //Get the currently logged in user data
    AnimateBar();
    print("1+");

    if (FirebaseAuthManager.DBreference != null)
    {
        print("nice");

        print("^12345678");
        Test();
        

        var DBTask = FirebaseAuthManager.DBreference.Child("users").Child(FirebaseAuthManager.auth.CurrentUser.UserId).GetValueAsync();

        print("1");

        yield return new WaitUntil(predicate: () => DBTask.IsCompleted);

        print("1-");

        if (DBTask.Exception != null)
        {
            Debug.LogWarning(message: $"Failed to register task with {DBTask.Exception}");
        }
        else if (DBTask.Result.Value == null)
        {
            //No data exists yet
            Pointstext.text = "Points: 0";
            print("No Points");
        }
        else
        {
           
            //Data has been retrieved
            DataSnapshot snapshot = DBTask.Result;
            print((snapshot.Child("Points").Value.ToString()));
            Points = float.Parse(snapshot.Child("Points").Value.ToString()); // Set the Points variable to the retrieved value
            Pointstext.text = "Points: " + Points.ToString(); // Set the Pointstext to the Points value
        }

        // Hier wird AnimateBar() aufgerufen, um die Leiste zurückzusetzen
        AnimateBar();
    }
    else if (FirebaseAuthManager.DBreference == null)
    {
        print("bad");
    }
}

}

I am not sure if this is related to the issue or not, but on line 151, you are calling a Corroutine function directly, and then the proper way:

 LoadUserDataCoroutine();
 StartCoroutine(LoadUserDataCoroutine());

As far as I know, there is generally no reason to call it directly as Unity will not be able to handle it properly, since Coroutines are not native to C#. It’s possible, but I am not sure, that this may be messing it up.

Like @rysan007 said, those 3 lines make not much sense but for a different reason:

             LoadUserDataCoroutine();
             StartCoroutine(LoadUserDataCoroutine());
             this.StartCoroutine(this.LoadUserDataCoroutine());

The first of those lines just does nothing besides generating garbage. It has no effect at all. Though you actually start your coroutine twice. That means you get two coroutines which run simultaneously. This is never a good idea, especially when doing some API requests.

Though your actual issue most likely comes from this:

     DBTask.ContinueWith(task =>
     {
          // [ ... ]

This will probably run your task on a separate thread. You can not call StartCoroutine from a different thread. It can only be called on the main thread. Read this forum thread for more details.