private void SafeAction(Action action) { if (action == null) return; if (this.InvokeRequired) { this.Invoke(action); } else { action.Invoke(); } }In this example, the SafeAction method takes in an Action delegate as an argument and checks whether it needs to be called using Invoke or directly. This ensures that the delegate is executed on the correct thread. Package Library: The SafeInvoke method is a part of the System.Windows.Forms package in C#.