I've confusing with using command line argument in VB.net Winform.
I'm created an application integrated with dlsrbooth. Dlsrbooth send a trigger via command line argument. (https://support.lumasoft.co/hc/en-us/articles/360000637854-Triggers-Webhooks-and-API)
dlsrbooth will send trigger 'session_end' at first time running and change trigger after we start to take a photo session.
Since dlsrbooth screen based trigger (when take picture, will be send another trigger) so I use timer to read the argument.
If I put check argument at main form (form 1), I can read each trigger. But if I put read argument at 4th form, I didn't receive next screen trigger, only first time running trigger (session_end trigger).
Imports System.Reflection.Emit
Public Class Form6
Private TargetDT As DateTime
Private TargetDT2 As DateTime
Private CountDownFrom As TimeSpan = TimeSpan.FromSeconds(60)
Private startFrom As TimeSpan = TimeSpan.FromSeconds(10)
Dim wait As TimeSpan
Public Sub checkstatus()
If (Val(Form6.Label1.Text) <= 0) Then
Try
Dim sCmdLine As String() = Environment.GetCommandLineArgs()
Using sw As New StreamWriter(strFile)
sw.WriteLine(sCmdLine(1))
sw.Flush()
End Using
Catch
End Try
End If
End Sub
Private Sub tmrCountdown_Tick(sender As Object, e As EventArgs) Handles tmrCountdown.Tick
Dim ts As TimeSpan = TargetDT.Subtract(DateTime.Now)
wait = TargetDT2.Subtract(DateTime.Now)
checkstatus()
Label1.Text = wait.Seconds.ToString
If ts.TotalMilliseconds > 0 Then
lbltimer.Text = ts.ToString("mm\:ss")
Else
lbltimer.Text = "00:00"
tmrCountdown.Stop()
Form1.Show()
Me.Close()
End If
End Sub
Private Sub Form6_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Width = lbltimer.Width
Height = lbltimer.Height
tmrCountdown.Interval = 1000
TargetDT = DateTime.Now.Add(CountDownFrom)
TargetDT2 = DateTime.Now.Add(startFrom)
tmrCountdown.Start()
End Sub
End Class
I already try put checkstatus in main form (form 1) and call it within timer in 4th form, but the result is same, can't read next screen trigger.
Is it possible to read command line argument on other form (not main form)? How? Or where form event that should I put the command line argument?
Note: I want to send "session_start" command via API but it's not working, so I'm delaying read trigger and read each second using timer.