Arsip: Custom Thread Error?
more 15 years ago
ir1keren
Gw punya mslh aneh (lagi, ato gw yg ga teliti?). Gw punya class turunan dr TThread yg deklarasinya:
TAlgo=class(TThread)
private
FVertex:TCollectionVertex;
FOnUpdate:TThreadProcedure;
FTick,FDTime:Cardinal;
FTotTime:Cardinal;
procedure SetVertex(V:TCollectionVertex);
procedure RecalculateTimer;
public
constructor Create;
....
Trus di-implementation, gw ksi:
constructor TAlgo.Create;
begin
inherited Create(True);
FTick:=0;
FTotTime:=0;
FDTime:=0;
FOnUpdate:=nil;
FreeOnTerminate:=True;
end;
mksudnya biar begitu Terminate langsung di-free. Trus gw bikin tombol yg OnClick-nya ky gini:
if Assigned(NetHopfield) then
Exit;
NetHopfield:=THopfield.Create;
NetHopfield.Vertex:=Vertices;
NetHopfield.OnUpdate:=OnHopfieldProcess;
NetHopfield.OnTerminate:=OnAfterHopfield;
...
NetHopfield.Resume;
NetHopfield tu turunan dari class TAlgo. Nah pas tombol diklik pertama, ok, proses jalan. Tp pas tombol diklik kedua kalinya muncul error:
"Thread Error: The handle is invalid(6)"
Trus gw trace, pas penekanan tombol kedua if Assigned(NetHopfield), eh malah dilewati. Jadi ternyata blm benar2 free, wajar klo pas NetHopfield.Resume muncul error.
Yawdah gw akalin,
constructor TAlgo.Create;
begin
inherited Create(True);
...
FreeOnTerminate:=False;
end;
Oya, properti Terminated gw deklarasi ulang jd public, biar bs kebaca di objek laen :). Trus di event OnClick, gw kasi
if Assigned(NetHopfield) then
if NetHopfield.Terminated then
FreeAndNil(NetHopfield)
else
Exit;
..
NetHopfield.Resume;
Maksudnya pas tombol ditekan ke sekian, otomatis NetHopfield di-free, n dibuat sbg objek baru gt.
Nah gw coba pas penekanan tombol kedua muncul pesan error:
"Access violation at address 0046ABC4..Read of address 000000"
dan dilanjutin dg pesan:
"System Error. Code: 5. Access is denied"
Kynya ada yg aneh, kan pas penekanan tombol kesekian harusnya objeknya di-create ulang? klo di-create ulang kan harusnya alamat memori, handle-nya benar2 baru?
Apa yg salah? ato gw ada yg terlewat ya dlm teknis multi-threading?
more 15 years ago
ir1keren
weeksss..salah forum index niiyy.. maksudnya ke "Bedah Kasus"..Tulung dipindahin..thx..
more ...
- Pages:
- 1
reply |
Report Obsolete
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 4 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago
Random Topic
- begin-end
by kaito_kid in Tip n Trik Pemrograman more 14 years ago - [ASK] Cara atur printer
by _liang in Reporting more 16 years ago - Minimize
by p2bf in Tip n Trik Pemrograman more 17 years ago - Client Server tdk perlu lock table secara programming ?
by delphi_warrior in Lain-lain more 15 years ago - Grouping Quick Report
by Soni in Paradox more 17 years ago - curhat: susahnya nyari tenaga IT yg specialized
by simba in OOT more 16 years ago - bagaimana menggunakan quick report
by divanda in Hal umum tentang Pascal Indonesia more 17 years ago - gimana cara filter data 2 kali ato lebih
by putukaca in Tip n Trik Pemrograman more 17 years ago - Analysis Manager
by ichan29 in MsSQL more 17 years ago - Permasalahan dengan gammu
by gita in Tip n Trik Pemrograman more 16 years ago