LOCK or ACQUIRELOCK?

I don’t understand the differences … I’ve multiple txt files and the goal is to append lines in them at the end of the config … Here an example :

IF STRINGKEY @BANQUE Contains "AXA"

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[1]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

ELSE IF STRINGKEY @BANQUE Contains "BNP"

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[2]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

ELSE IF STRINGKEY @BANQUE Contains "BANQUE POSTALE"

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[3]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

ELSE IF STRINGKEY @BANQUE Contains "CRCAM"

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[4]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

ELSE IF STRINGKEY @BANQUE Contains "CAISSE D"

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[5]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

ELSE IF STRINGKEY @BANQUE Contains "CIC"

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[6]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

ELSE IF STRINGKEY @BANQUE Contains "CREDIT MUTUEL"

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[7]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

ELSE IF STRINGKEY @BANQUE Contains "CREDIT LYONNAIS"

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[8]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

ELSE IF STRINGKEY @BANQUE Contains "STE GENERALE"

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[9]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

ELSE

BLOCK:FileAppend

LABEL:Ajouter ligne

  path = $"<globals.CHEMINIBAN[0]>"

  content = $"<input.USERNAME>:<input.PASSWORD>|<nom>|<IBAN>|<BANQUE>\\n"

ENDBLOCK

END

What’s the best to use ?

LOCK translates to a lock statement in C#
ACQUIRELOCK translates to an async lock so you can place async blocks inside.

Use ACQUIRELOCK and then RELEASELOCK it’s much better.

But I’m not sure you even need to use locks here… files are already locked by OB2 itself so that only 1 thread can write at any given time

1 Like