hi
i have a b4j app and i use threading library (b4a version in b4j)
when i use "mythread.start" method i dont have a problem\
but when i use "mythread.RunOnGuiThread" my app is hang until the operation end.
in this method the sub are runing that load panel and leyout and tableview
this app is telegram bot and have many users
perhaps in onetime many users use the program and run this sub
actually no different between use and not use thread in RunOnGuiThread for me
It still hangs in two case (with thread and without thread)
anyone can help me to solve this problem ??
my sub :
i have a b4j app and i use threading library (b4a version in b4j)
when i use "mythread.start" method i dont have a problem\
but when i use "mythread.RunOnGuiThread" my app is hang until the operation end.
in this method the sub are runing that load panel and leyout and tableview
this app is telegram bot and have many users
perhaps in onetime many users use the program and run this sub
actually no different between use and not use thread in RunOnGuiThread for me
It still hangs in two case (with thread and without thread)
anyone can help me to solve this problem ??
B4X:
Dim args(2) As Object
args(0)=from.Id
args(1)=counter1
mythread.Priority=mythread.MinPriority
mythread.RunOnGuiThread("snapshot",args)
my sub :
B4X:
Sub snapshot(uid As Int,counter As Int)
Dim p As Pane
p.Initialize("")
p.LoadLayout("hesabdari_printley")
'p.SetSize(1100dip,900dip)
p.Visible=False
MainForm.RootPane.AddNode(p,0,0,1100,900)
lbl_userfullname.Text=bardasht_list.get_fullname(uid)
lbl_datehesabdari.Text=today&" "&DateTime.time(DateTime.Now)
TableView1.SetColumnWidth(0,110)
TableView1.SetColumnWidth(1,610)
TableView1.SetColumnWidth(2,110)
TableView1.SetColumnWidth(3,100)
TableView1.SetColumnWidth(4,108)
TableView1.SetColumnWidth(5,50)
TableView1.SingleCellSelection=False
TableView1.Items.Clear
asJO(TableView1).RunMethod("setFixedCellSize",Array(40.0))
TableView1.Style="-fx-font-size: 14;-fx-font-family: tahoma;"
SetColumnStyle(0, "-fx-alignment: CENTER;")
SetColumnStyle(1, "-fx-alignment: CENTER_right;")
SetColumnStyle(2, "-fx-alignment: CENTER;")
SetColumnStyle(3, "-fx-alignment: CENTER;")
SetColumnStyle(4, "-fx-alignment: CENTER;")
SetColumnStyle(5, "-fx-alignment: CENTER;")
File.MakeDir(File.DirApp, "/user_reports")
Dim RS As ResultSet=Sql1.ExecQuery2("SELECT * FROM hesabdari OFFSET LIMIT ?,?",Array As String(counter,19))
Dim ii As Int=counter+1
Do While RS.NextRow
If RS.GetString("userid")=uid Then
Dim Row(6) As Object
Row(5)=ii
Row(4)=RS.GetString("type")
Row(3)=NumberFormat( RS.GetString("mablagh"),0,0)
Row(2)=NumberFormat( RS.GetString("mandeh") ,0,0)
Row(1)=RS.GetString("tozihat")
Row(0)= unix_to_time(RS.GetString("date"))
TableView1.Items.Add(Row)
ii=ii+1
End If
Loop
Dim bmp As B4XBitmap = Pane1.Snapshot
Dim out As OutputStream
Dim filename As String=uid&Rnd(1,200)&".png"
out = File.OpenOutput(File.DirApp&"/user_reports", filename, False)
bmp.WriteToStream(out, 100, "PNG")
out.Close
''''''''''''''''''''''''''''''
jtb2.sendPhoto(jtb2.byId(uid),jtb2.MediaByFile(File.DirApp&"/user_reports",filename),"test",True,Null,Null)
'''''''''''''''''''''''''''
File.Delete(File.DirApp&"/user_reports", filename)
End Sub
Last edited: