0

I have my main method calling another method. Everything works fine as long as I use Console.Readline() or Console.ReadKey(). The minute I remove it, the project is finishing without doing completely what it is supposed to do.

private static void Main()
{
    var SQLServerName = "XXXXXXXXXXXX.database.windows.net";
    var SQLServerAdmin = "XXXXXXXXXXXX";
    var SQLServerAdminPasword = "XXXXXXXXXXXX";
    var DatabaseName = "XXXXXXXXXXXX";
    string SQLStatement = ($"TRUNCATE TABLE XXXXXXXXXXXX" + 
                           $"TRUNCATE TABLE XXXXXXXXXXXX");
    Helper.ExecuteTSQL(SQLServerName, SQLServerAdmin, SQLServerAdminPasword, DatabaseName, SQLStatement);

    List<string> Subscriptions = Helper.GetSubscriptionList();
    foreach (string Subscription in Subscriptions)
    {
        string SubscriptionID = Subscription.Replace(" ", String.Empty);
        Runner(SubscriptionID);
    }
    Console.ReadKey();
}

public static async void Runner(string SubscriptionID)
{
   var task = await RBACSnapshot.GetRBACSnapshot(SubscriptionID);   
}
Peter Duniho
  • 68,759
  • 7
  • 102
  • 136
Vinny
  • 461
  • 1
  • 5
  • 18
  • But when I publish the project in azure functions, I need to remove the Console.ReadKey(); right. then will the project do what it is supposed do? – Vinny Jul 29 '21 at 04:38
  • 1
    You are calling an async method without the await keyword "Runner" – Sameer Jul 29 '21 at 04:43
  • What @Sameer said – TheGeneral Jul 29 '21 at 04:44
  • Now I changed the Runner Method to public static void Runner. Still no luck. WHat should i do to get rid of Console.ReadKey( – Vinny Jul 29 '21 at 05:10
  • @Knoop. Tried your thing but this is making the Runner Method go in synchronous mode. I need Runner to fireoff asynchronously on each subscription. – Vinny Jul 29 '21 at 18:59

0 Answers0