Sign in to follow this  
Followers 0
MadBoy

Problem With One Instance Of Script

3 posts in this topic

Hey. I have compiled script that has UDP Server/Receiver functions. That's why i need to make sure it's not started again or it will return error to user. So i used _Singleton and tried to use ProcessExists too and it seemed to work fine but.. Whenever another instance is started, msgbox apears, script exists but it also crashes saying that "AutoIt crashed and i am asked if i want to send msg to Microsoft to solve the problem". Also if i will not use _Singleton/ProcessExists and just have those If @error <> 0 Then Exit it also crashes. I would rather expect it to just 'exit' as it is told to. Maybe it's some bug or maybe my usage is bad.

if _Singleton($tag,1) = 0 Then
    Msgbox(0,"Warning","An occurence of UdpServer is already running. Terminating!")
    Exit
EndIf

UDPStartup()
$socket_incoming = UDPBind($listening_udp_ip, $listening_udp_port)
If @error <> 0 Then Exit
$socket_outgoing = UDPOpen($udp_ip, $udp_port)
If @error <> 0 Then Exit

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Does it crash before or after?

Msgbox(0,"Warning","An occurence of UdpServer is already running. Terminating!")
Could it be that you do some cleanup (using a OnAutoItExit function?) on termination?

Edited by Uten

Share this post


Link to post
Share on other sites

Does it crash before or after?

Msgbox(0,"Warning","An occurence of UdpServer is already running. Terminating!")
Could it be that you do some cleanup (using a OnAutoItExit function?) on termination?
It crashes after msgbox.

Good question :) And the answer is YES.

Func OnAutoItExit()
    UDPCloseSocket($socket_incoming)
    UDPCloseSocket($socket_outgoing)
    UDPShutdown()
EndFunc

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0