This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using CursorLang.Core.Services;
|
||||
|
||||
namespace CursorLang.Agent;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// A single-threaded apartment because of the caret: <c>AccessibleObjectFromWindow</c>
|
||||
/// and UI Automation both go through COM, and both expect the thread that calls them
|
||||
/// to be an STA one.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
private static int Main(string[] arguments)
|
||||
{
|
||||
bool automatic = StartupLaunch.IsAutomatic(arguments);
|
||||
|
||||
var gate = new SingleInstanceGate(SingleInstanceGate.AgentName);
|
||||
|
||||
// A second launch is the user asking for the application, so the one already
|
||||
// running opens the settings window and this one steps aside. A second launch
|
||||
// by Windows at sign-in asks for nothing and gets nothing
|
||||
if (!gate.TryAcquire(showRunningInstance: !automatic))
|
||||
{
|
||||
gate.Dispose();
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var agent = new Agent(gate);
|
||||
return agent.Run(automatic);
|
||||
}
|
||||
finally
|
||||
{
|
||||
gate.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user