But in new Native API for IRIS there are no proxies, just class methods/functions are called from app and I think, it should be pretty the same as calling this methods/functions from terminal window.

Introduction to the Native API

Using .NET Reverse Proxy Objects

The Native API allows you to create instances of ObjectScript classes on InterSystems IRIS and generate Object Gateway proxy objects for them at runtime. Your .NET application can use proxies to work with ObjectScript objects as easily as if they were native .NET objects.

Yes, most likely this is a feature of the API.
Here's what I found about it in the "old" documentation:

In some situations, caching may not be desirable. For example, if an object is opened with Concurrency Level 4 (Exclusive Lock), the lock will not be released until the next server call. To destroy the object immediately, you can call Close() with the optional useCache parameter set to false

Closing Proxy Objects

PS: by the way, for ActiveX, Factory.ForceSync() method serves the same purpose.

I did a test and that's what found out.
It is assumed that the data has already been generated.

COS

Class dc.test Extends %Persistent
{

ClassMethod Checking(CardNo As %StringAs %String
{
  tmp=..%OpenId(CardNo,4)
  "test"
}

}

If executed from the terminal, the lock is removed automatically immediately after the method is completed:

USER>##class(dc.test).Checking("1")
test

C#

// ...
string json = iris.ClassMethodString("dc.test""Checking""1");
 
// here the lock is still present
 
db.ReleaseIRISObjects(); // or iris.ReleaseAllLocks();
 
// here already more is no lock
  1. ProcedureBlock does not apply to your issue at all
  2. you didn't initially indicate that the issue is with C#
  3. use ReleaseIRISObjects

    Example:

    IRISConnection db; IRIS iris; IRISObject person;   // ...   using (person = (IRISObject)iris.ClassMethodObject("Sample.Person""%OpenId""1""4")) {   }   /* or   person = (IRISObject)iris.ClassMethodObject("Sample.Person", "%OpenId", "1", "4") person.Dispose(); person = null; */   db.ReleaseIRISObjects();

And if so?

ClassMethod TestLock() As %Status
{
    New id,obj

    Set id $Order(^ZUser.NewClass1D(""))
    If id "" {
        Set obj ##class(ZUser.NewClass1).%New()
        Do obj.%Save()
    }

    Set id $Order(^ZUser.NewClass1D(""))

    Set obj ##class(ZUser.NewClass1).%OpenId(id, 4)

    ; in case of usage Not ProcedureBlock you should 
    ; kill obj or set obj="" (and all others variables with this object reference) to release the lock

    Return $$$OK
}

COS:

Class dc.DPasarela Extends %RegisteredObject
{

Property STREAM As %Stream.TmpBinary;

Method PostMsg()
{
  s=$tr($j("",$$$MaxStringLength)," ",$c(0))

  i=1:1:5 ..STREAM.Write(s)
}

}

C#

IRISObject STREAM;
MemoryStream stream = new MemoryStream();
string len1, len2;
 
IRISObject pasarela = (IRISObject)iris.ClassMethodObject("dc.DPasarela""%New");
 
pasarela.InvokeVoid("PostMsg");
 
STREAM = (IRISObject) pasarela.Get("STREAM");
 
while (!Convert.ToBoolean(STREAM.GetBool("AtEnd")))
{
    stream.Write(STREAM.InvokeBytes("Read"3641144),03641144);
}
 
len1 = STREAM.GetString("Size"); // 18205720 (3641144*5)
len2 = stream.Length.ToString(); // 18205720 (3641144*5)
 
// =========== AGAIN ===========
 
STREAM.InvokeVoid("MoveToEnd");
 
pasarela.InvokeVoid("PostMsg");
 
stream.SetLength(0);
 
while (!Convert.ToBoolean(STREAM.GetBool("AtEnd")))
{
    stream.Write(STREAM.InvokeBytes("Read"3641144)03641144);
}
 
len1 = STREAM.GetString("Size"); // 36411440 (18205720*2)
len2 = stream.Length.ToString(); // 36411440 (18205720*2)
 
byte[] bytesS = stream.ToArray();

COS:

Class dc.DPasarela Extends %RegisteredObject
{

Property Value As %Numeric;

Property Title As %String;

Property Message As %String;

Property STREAM As %Stream.TmpCharacter;

Method PostMsg(
  SessionId As %String,
  Msg As %String,
  bytesS As %Binary,
  STREAMin As %Stream.TmpCharacter,
  Output STREAMout As %Stream.TmpCharacter)
{
  set ..Value = 5,
      ..Title SessionId,
      ..Message Msg_" "_bytesS
  
  do:$IsObject(STREAMin) ..STREAM.CopyFrom(STREAMin)
  
  set STREAMout=##class(%Stream.TmpCharacter).%New()
  do STREAMout.Write("bla-bla-bla")
}

}

C#:

IRISObject pasarela = (IRISObject)iris.ClassMethodObject("dc.DPasarela""%New");
 
byte[] bytesS = new byte[3]; // In real world this is a BASE64 encoded JSON
bytesS[0] = 233; // é
bytesS[1] = 234; // ê
bytesS[2] = 59; // ;
 
IRISReference refSTREAMout = new IRISReference(null);
 
IRISObject STREAMin = (IRISObject)iris.ClassMethodObject("%Stream.TmpCharacter""%New");
STREAMin.InvokeString("Write","blablabla");
 
pasarela.InvokeVoid("PostMsg""aSession""aMsg", bytesS, STREAMin, refSTREAMout);
 
int aValue = Convert.ToInt32(pasarela.GetLong("Value")); // 5
string aTitle = pasarela.GetString("Title"); // aSession
string aMessage = pasarela.GetString("Message"); // aMsg éê;
string aSTREAMout = ((IRISObject)refSTREAMout.value).InvokeString("Read"); // bla-bla-bla
string aSTREAM = ((IRISObject)pasarela.GetObject("STREAM")).InvokeString("Read"); // blablabla

and second, I would like to read the doc everywhere! For example, I have a 10 hour flight, and want to work. And in case, a server only has a local LAN access, then you have no docu!).

I fully support it.
But I'm afraid now, apart from reading the documentation in PDF format, you can forget about local documentation ("DOCBOOK" database) with normal search and navigation. It's a pity..

See %SQL.StatementResult:%DisplayFormatted()

Simple sample (for namespace "SAMPLES"):

set st ##class(%SQL.Statement).%New(2,"Sample")
set sql = 3
set sql(1) = "select TOP 5 %ID as id, Name, DOB, Home_State"
set sql(2) = "from Person where Age > 40"
set sql(3) = "order by 2"
do st.%Prepare(.sql)
for type="txt","pdf","csv","html","xml" {
  set rs st.%Execute()
  do rs.%DisplayFormatted(type,"C:\Temp\report")
}

As a result, the following files are generated:

report.csv
report.html
report.pdf
report.txt
report.xml

Instead of

set str=$e(str,1,*-1)

, will be a little faster

set $e(str,*)=""

But this is already saving on matches.

PS: for the sake of interest, I checked on a special version of Caché (very old) with server-side JavaScript (not to be confused with Node.js)

 
Source code
USER>##class(dc.test).Test(1800000)
[JavaScript] execution: 99(ms) len(str): 3599999
[COS] execution: 126.683(ms) len(str): 3599999

By the way, the JS code has almost no limit on the string size.

 
An example without complex formulas and very fast

Simple sample:

Class dc.test Extends %ZEN.Component.page
{

XData Contents [ XMLNamespace "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen">
  <tablePane
    id="tp"
    sql="select ID,'Western branch' Branch,{'2021-03-15'&quot;Date&quot;,35 Suma
    union
    select 2,'Eastern branch',{'2020-12-11'},37"
  />
  <button caption="Row unselect" onclick="zenPage.rowUnselect()"/>
</page>
}

ClientMethod rowUnselect() [ Language = javascript ]
{
  var tp=zen('tp');
  row=tp.selectedIndex;

  if (tp.rowSelect && row>=0) {
    var old=tp.enableToggleSelect;

    tp.enableToggleSelect=true;
    tp.selectRow(row);
    tp.enableToggleSelect=old;
  }
}

}

I also will insert my five kopecks.

  • The %Library package also includes stream classes, but those are deprecated. The class library includes additional stream classes, but those are not intended for general use.
    Working with Streams
    I have %Stream.FileCharacter was an order of magnitude faster than %[Library.]File
  • If you rewrite the line-by-line reading to read blocks with further parsing of lines, the speed will more increase by an order of magnitude.
     
    Sample
  • On the Internet, you can find a lot of materials about comparing the speed of reading files (in particular CSV) for different programming languages (Python, C/C++, R, C#, Java, etc.), for example (this is machine translation). Often, those who make such comparisons do not always know all these languages equally well, so sometimes casus happen.
     
    Who do you think in the article above was faster when reading 1e7+ lines: Fortran or C++ ?
  • If we approach the issue formally, then the advantage will be given to compiled languages, not interpreted ones, as well as the implementation that uses all the capabilities of the operating system and hardware.