كيف نتجنب نعليق البرنامج في خالة for loop high counts
#1
ادا كان البرنامج يعمل لوب اكثر من 20 الف مرة
البرنامج يعلق بعد 2300 مرة

PHP كود :
TForm1 = class(TForm)
 
   Start_BTN_TButton;
 
   Memo1TMemo;
 
   Memo2TMemo;
 
   Label1TLabel;
 
   Label2TLabel;
 
   Label3TLabel;
 
   Button2TButton;
 
   Button1TButton;
 
   CurvyCombo1TCurvyCombo;

 
   procedure FormActivate(SenderTObject);
 
   procedure Start_BTN_Click(SenderTObject);
 
   procedure Button2Click(SenderTObject);
 
   procedure Memo1Change(SenderTObject);
 
   procedure Memo2Change(SenderTObject);
 
   procedure ListBox1Click(SenderTObject);
 
   procedure Button1Click(SenderTObject); 


كود :
for I := 0 to Line_count-1 do
       begin
end;
الرد
#2
لا يمكن معرفة السبب الا بمعرفة محتوى الحلقة
الرد
#3

السلام عليكم

ضف هذا السطر داخل الحلقة

كود :
Application.ProcessMessages;
رَبَّنَا اغْفِرْ لِي وَلِوَالِدَيَّ وَلِلْمُؤْمِنِينَ يَوْمَ يَقُومُ الْحِسَابُ
الرد
#4
منتطر ردكم من ساعات طويلة رمضان كريم

100 /100
اعطني ليست هدا الكود Big Grin
[صورة: good.jpg]
الرد
#5
لقد تم حل التعليق بنجاح ولكن الوب ياخد وقت طويل
كيف يمكن انستخدم multi thread
افكر بتقسيم   Line_count-1


AUTO DYNAMIC
يعني لو كان عدد الوب كبير فسوف يتقسم بشكل الي الى عدد مناسب من TTHREAD or TTHREADLIST
وبالتالي يكون الهدف تقليل زمن نتفيد العملية الى افصى جد ممكن

PHP كود :
Proxy_Thread =class(TThread)
 
  protected
 
  procedure Execute override ;
 
end;

procedure TForm1.Start_BTN_Click(SenderTObject);
begin
       with  Proxy_Thread
.Create do
 
            FreeOnTerminate:=True ;

end
الرد
#6
PHP كود :
unit Unit1;

interface

uses
  Forms
DialogsWindowsSysUtilsVcl.ControlsVcl.StdCtrlsSystem.Classes;

type
  TForm1 
= class(TForm)
 
   Button1TButton;
 
   Button2TButton;
 
   Button3TButton;
 
   ListBox1TListBox;
 
   Button4TButton;
//    Button1: TButton;
//    Button3: TButton;
//    ListBox1: TListBox;
//    Button2: TButton;
//    Button4: TButton;
 
   procedure Button1Click(SenderTObject);
 
   procedure Button3Click(SenderTObject);
 
//   procedure FormCreate(Sender: TObject);
 
   procedure Button2Click(SenderTObject);
 
   procedure Button4Click(SenderTObject);
 
//   procedure FormDestroy(Sender: TObject);
 
 private
    
{ Private declarations }
 
 public
    
{ Public declarations }
 
 end;
 
 TListThread = class(TThread)
 
 protected
    procedure Execute
override;
 
 end;
 
 TMyThread = class(TThread)
 
 protected
    procedure Execute
override;
 
 end;
 
 TYouThread = class(TThread)
 
 protected
    procedure Execute
override;
 
 end;

var
 
 Form1TForm1;
 
 threadList1TThreadList;
 
 mythreadRunningyouthreadRunninglistThreadRunningBoolean;
 
 globalCountInteger;
 
 listProcessTListThread; { TListThread is a custom descendant of TThread. }
 
 secondProcessTMyThread; { TMyThread is a custom descendant of TThread. }
 
 otherSecondProcessTYouThread; { TMyThread is a custom descendant of TThread. }

implementation

{$R *.dfm}

procedure TForm1.Button1Click(SenderTObject);
begin
  if 
(mythreadRunning FALSEthen
  begin
    mythreadRunning
:= TRUE;
 
   secondProcess := TMyThread.Create(True); { Create suspended--secondProcess does not run yet. }
 
   secondProcess.FreeOnTerminate := True; { You do not need to clean up after termination. }
 
   secondProcess.Priority := tpLower // Set the priority to lower than normal.
 
   secondProcess.Resume; { Now run the thread. }
 
 end
  else
    MessageDlg
('This thread is still running.  You are going to hurt yourself!',
 
     mtInformation, [mbOk], 0);
end;

procedure TMyThread.Execute;
var
 
 IInteger;
 
 myRadioTRadioButton;
begin
  for I 
:= 0 to 20 do
 
 begin
    if 
(Terminatedthen
    begin
      mythreadRunning
:= FALSE;
 
     exit;
 
   end;
 
   myRadio:= TRadioButton.Create(Form1);
 
   globalCount:= globalCount 1;
 
   myRadio.Name:= 'RadioButton' IntToStr(globalCount);
 
   threadList1.Add(myRadio);
 
   Sleep(1000);
 
 end;
 
 mythreadRunning:= FALSE;
end;

procedure TForm1.Button2Click(SenderTObject);
begin
  if 
(listthreadRunning FALSEthen
  begin
    listThreadRunning
:= TRUE;
 
   listProcess := TListThread.Create(True); { Create suspended--secondProcess does not run yet. }
 
   listProcess.FreeOnTerminate := True; { You do not need to clean up after termination. }
 
   listProcess.Priority := tpLower // Set the priority to lower than normal.
 
   listProcess.Resume; { Now run the thread. }
 
 end;
end;

procedure TListThread.Execute;
var
 
 IInteger;
 
 TempTControl;
 
 myListTList;
begin
  while
(True) do
 
 begin
    if 
(Terminatedthen
    begin
      listthreadRunning
:= FALSE;
 
     exit;
 
   end;
 
   Form1.ListBox1.Clear;
 
   myList:= threadList1.LockList;
 
   try
      for I 
:= 0 to myList.Count-do
 
     begin
        Temp
:= myList.Items[I];
 
       Form1.ListBox1.Items.Add(Temp.Name);
 
     end;
 
   finally
      threadList1
.UnlockList;
 
   end;
 
   Sleep(1000);
 
 end;
 
 listthreadRunning:= FALSE;
end;

procedure TForm1.Button3Click(SenderTObject);
begin
  if 
(youthreadRunning FALSEthen
  begin
    youthreadRunning
:= TRUE;
 
   otherSecondProcess := TYouThread.Create(True); { Create suspended--secondProcess does not run yet. }
 
   otherSecondProcess.FreeOnTerminate := True; { You do not need to clean up after termination. }
 
   otherSecondProcess.Priority := tpLower // Set the priority to lower than normal.
 
   otherSecondProcess.Resume; { Now run the thread. }
 
 end
  else
    MessageDlg
('This thread is still running.  You are going to hurt yourself!',
 
     mtInformation, [mbOk], 0);
end;

procedure TForm1.Button4Click(SenderTObject);
begin
  if 
(listProcess <> nilthen
    listProcess
.Terminate;
 
 if (secondProcess <> nilthen
    secondProcess
.Terminate;
 
 if (otherSecondProcess <> nilthen
    otherSecondProcess
.Terminate;
end;

procedure TYouThread.Execute;
var
 
 IInteger;
 
 TempTControl;
begin
  for I 
:= 0 to 10 do
 
 begin
    if 
(Terminatedthen
    begin
      youThreadRunning
:= FALSE;
 
     exit;
 
   end;
 
   with threadList1.LockList do
 
   try
      if 
(2*Countthen
      begin
        Temp
:= Items[2*I];
 
       threadList1.Remove(Temp);
 
     end;
 
   finally
      threadList1
.UnlockList;
 
   end;
 
   if (Terminatedthen
      MessageDlg
('youThread has been asked to terminate, but is still running!',
 
       mtInformation, [mbOk], 0);
 
   Sleep(3000);
 
 end;
 
 youthreadRunning:= FALSE;
end;


end
وجدنا مثال ولكن يعمل
الرد
#7
السلام عليكم

يمكنك الاستفادة من الملفات المصدرية ل Port Scanner من برمجة المبدع
Assarbad
http://delphi4arab.net/forum/showthread.php?tid=1162
رَبَّنَا اغْفِرْ لِي وَلِوَالِدَيَّ وَلِلْمُؤْمِنِينَ يَوْمَ يَقُومُ الْحِسَابُ
الرد
#8
نشكركم على هدا السوزس
ولكن اغلب او كلهم اقصد البورت تشتغل
المقصود اننا نبحث اكواد تقوم بفحص البركسي
وتحدد حميع خواصة مثل timeout or uptime
and spead
https://www.youtube.com/watch?v=3CRjXq6vx1M
الرد
#9
(09-05-2019, 06:52 AM)FRXstar كتب : المقصود اننا نبحث اكواد تقوم بفحص البركسي
الملفات مصدرية للدراسة والاستفادة منها كمثال فقط
رَبَّنَا اغْفِرْ لِي وَلِوَالِدَيَّ وَلِلْمُؤْمِنِينَ يَوْمَ يَقُومُ الْحِسَابُ
الرد
#10
هل هناك دالة او كمبوننت تقوم بترتيب الارقام تصاعديا او العكس
لاحظ لديبنا 5 اجزاء جميعها ارقام صحيحة
PHP كود :
85.221.189.46:35139
247.114.206.118
:39638
213.148.154.43
:15818
24.223.9.202
:31188
228.246.145.151
:66448
118.137.153.44
:46239
73.235.89.61
:60507
196.135.198.23
:83138
109.75.137.144
:21813
62.164.32.86
:68618
70.238.34.26
:93505
226.223.16.237
:63589
176.188.63.62
:98975
65.118.82.124
:24646
66.5.135.242
:78300
148.229.58.106
:66709
241.12.33.12
:76332
65.27.249.251
:62248
180.195.207.157
:73488
191.120.131.186
:57640
207.44.128.177
:71039
50.212.94.92
:89948
177.120.40.138
:62146
87.55.195.196
:95576
145.99.79.233
:89812
80.64.80.146
:73335
108.148.212.145
:93182
170.87.73.16
:16412
88.15.194.97
:91093
133.124.222.99
:88864
39.3.103.36
:24461
228.40.133.31
:75354
232.114.254.212
:93102
155.131.169.30
:60679
6.96.43.201
:44470
235.252.95.247
:86284
187.46.167.51
:98520
252.179.145.234
:88869
71.136.35.146
:91342
70.60.122.218
:50276
146.27.41.23
:70454
223.113.18.211
:43642
175.229.30.108
:81447
237.20.180.71
:53229
142.229.167.147
:63702
65.121.39.216
:98072
19.148.46.225
:72116
190.11.75.127
:45080
189.147.74.37
:42989
25.114.204.130
:64454
160.104.3.227
:61012
117.127.254.40
:23630
167.124.240.169
:18959
116.121.247.61
:53988
96.131.65.232
:22522
106.51.103.144
:17242
150.242.3.163
:17874
154.64.18.65
:50901
198.129.137.199
:68022
218.173.54.5
:37314
40.4.148.102
:45844
233.0.91.89
:61713
71.77.2.225
:13264
91.17.80.111
:94186
60.47.16.45
:31954
229.212.238.206
:22970
128.16.75.83
:31379
38.65.176.254
:87830
123.130.229.70
:94918
185.163.240.242
:13486
101.158.68.214
:79877
18.152.207.30
:65022
128.116.19.214
:90796
87.250.160.211
:43154
7.125.151.105
:68632
220.102.199.153
:73387
124.48.161.189
:50843
197.240.97.128
:40958
165.85.184.7
:64838
12.220.14.182
:39076
82.11.159.79
:22250
93.77.34.220
:18633
41.57.8.130
:98920
107.92.53.157
:80555
250.252.34.78
:26710
214.110.49.246
:98502
91.119.80.85
:50594
137.62.96.72
:50872
13.101.24.222
:24558
103.18.125.201
:93235
209.209.13.112
:98163
202.93.62.211
:92904
224.43.122.138
:23018
8.229.117.74
:40214
79.214.56.254
:19463
147.47.232.152
:85436
32.195.88.39
:38492
227.134.143.162
:24210
106.227.183.116
:64326
98.212.69.185
:37557
231.54.160.24
:10023
211.149.13.11
:90186
18.80.49.14
:86244
9.209.217.208
:74262
33.104.53.135
:72566
87.186.170.1
:82111
26.13.91.77
:33848
244.173.86.165
:29618
246.50.235.3
:22392
35.127.113.195
:30188
11.174.234.245
:90422
130.51.27.246
:36680
50.215.11.227
:68413
1.219.31.119
:55904
243.108.99.162
:45141
221.202.81.194
:99320
221.173.160.145
:37214
149.245.139.243
:82136
11.187.211.230
:89840
52.35.162.87
:32011
248.33.233.173
:15528
176.65.78.107
:74645
239.3.223.171
:47122
75.164.134.131
:75372
66.163.21.179
:29882
92.235.8.233
:37279
109.231.174.3
:60684
190.31.44.254
:25479
251.94.75.106
:43718
20.0.232.79
:83006
137.19.163.231
:92876
210.39.104.137
:99818
105.196.150.230
:10084
169.10.15.208
:40229
110.70.233.165
:47651
96.188.113.45
:87611
50.112.126.157
:99695
91.123.16.162
:58858
1.67.203.157
:82021
192.143.165.182
:66271
145.206.1.41
:70049
219.131.9.106
:52308
250.230.160.127
:62554
163.254.229.201
:99230
141.48.84.162
:89076
184.137.245.180
:84345
107.25.75.190
:69412
106.147.12.185
:87463
160.129.8.8
:52904
230.211.247.154
:89316
26.242.180.27
:66921
219.17.54.5
:83259
237.126.9.162
:12204
82.226.187.114
:27836
199.124.178.61
:79359
91.192.233.102
:67319
229.163.201.130
:28059
99.182.88.120
:18450
212.159.197.74
:83766
108.70.251.251
:80021
0.232.39.191
:84170
158.126.194.92
:90830
156.197.79.51
:72932
106.75.160.15
:36911
170.209.109.75
:59651
78.177.88.211
:36027
193.160.153.212
:82249
120.42.76.33
:45963
179.201.162.239
:45242
231.13.12.140
:41466
183.179.120.18
:79640
10.238.55.48
:16973
50.251.208.50
:55284
216.11.138.151
:39492
102.185.146.147
:22288
69.20.210.224
:48361
158.28.209.180
:24813
181.178.73.110
:66053
109.150.1.98
:46727
16.229.194.61
:94470
184.141.229.127
:13339
173.80.75.10
:20177
168.134.181.132
:18578
231.230.129.139
:71943
144.103.240.17
:80197
151.253.16.6
:70551
216.182.88.251
:40252
179.148.64.188
:14313
86.161.144.170
:83257
233.69.125.50
:62339
151.66.190.107
:37488
154.136.50.99
:85460
195.233.154.161
:19878
53.226.140.226
:86764
176.239.91.245
:21832
147.172.109.134
:13678
181.80.164.174
:77899
65.114.29.152
:71630
80.167.110.206
:38338
49.179.147.192
:58622 

طبعا الهدف دالة ترتيب index of lines وليس تعديل على البروكسي
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم