C# Queueing up methods

I am looking for a way to call method 2 from method 1 but only after method 1 has completed.

I am considering queueing up the methods with an action list:
List queue = new List();

Then instead of calling methods, I’ll queue them up and let a processing loop have at them. Is this stupid? Is there a better way? Cough @josecgomez.sixs Cough

You could simply call method 2 after you are done processing within method 1, if I understand this right, and you are not doing anything async. If you queue up the two methods you are technically calling both of them from a 3rd method. The example below would be much like what you would use should you add them to a queue and they would be FIFO.

 List<Action que = new List<Action();
 Func<string, string msgHandler = (msg) = {
	Epicor.Customization.Bpm.InfoMessage.Publish(msg);
	return string.Empty;
 };
 msgHandler("Pre Processing");
 que.Add(() = { msgHandler("First Method"); });
 que.Add(() = { msgHandler("Second Method"); });

 foreach (Action item in que)
 {
	  item();
 }
 msgHandler("Post Processing");

Can’t you just do a Post Processing bpm?

Thanks, I was thinking something similar as what you describe Dan. This will actually be running in a Customization, not a BPM.

queue.Add(() => { RemoveAllMasters("M1"); });
queue.Add(() => { DeleteMaster("M1"); });
queue.Add(() => { RefreshLabels(); });

//processing loop
foreach (Action ActionItem in queue)
{
     ActionItem();
}

I have a lot of helper functions - picture this:
RemoveMasterLabel = ClearMasterOfChildren - RemoveMasterLabel - Refresh - SuggestNewMaster -CalculateMasterQty - Refresh
SuggestNewMaster = Prompt - AddNewMaster (if needed) - SetMasterOfChildren - CalculateMasterQty -Refresh

This is a horrible explanation but essentially I have nested actions which are causing issues because the current action is not complete. I need to run all of these to a queue to ensure they finish in order.