Nur läuft es nicht richtig.
Es hängt sich auf, und es kommt von GTK" eine Fehlermeldung.
Lasse ich das Lines.Add weg, funktioniert es, das Writeln geht.
Code: Alles auswählen
uses
cthreads,
...
function thread_cb(parameter: pointer): ptrint;
var
pc: PChar absolute parameter;
begin
Sleep(1000); // mache etwas
WriteLn(pc);
Form1.Memo1.Lines.Add('blabla');
Result := 0;
EndThread(0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
BeginThread(@thread_cb, PChar('Thread 1'));
BeginThread(@thread_cb, PChar('Thread 2'));
BeginThread(@thread_cb, PChar('Thread 3'));
BeginThread(@thread_cb, PChar('Thread 4'));
end;
Code: Alles auswählen
(project1:5025): Gtk-WARNING **: 13:58:54.808: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a position across buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset)
will invalidate all outstanding iterators
Thread 3
Thread 2
Thread 1
Thread 4
**
Gtk:ERROR:../../../../gtk/gtktextiter.c:1779:forward_line_leaving_caches_unmodified: assertion failed: (!_gtk_text_line_is_last (new_line, real->tree))
Bail out! Gtk:ERROR:../../../../gtk/gtktextiter.c:1779:forward_line_leaving_caches_unmodified: assertion failed: (!_gtk_text_line_is_last (new_line, real->tree))
Abgebrochen (Speicherabzug geschrieben)
Dazuml habe ich einen Mutex gesperrt.
Code: Alles auswählen
pthread_mutex_lock(@mutex);
Write(Thread.index, ' ');
pthread_mutex_unlock(@mutex);