Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Сети";
Текущий архив: 2003.03.06;
Скачать: [xml.tar.bz2];

Вниз

Как организовать пинг в отдельном потоке?   Найти похожие ветки 

 
Junior   (2003-01-15 14:31) [0]

Т.е. Как сделать ентот самый поток? Может еще подскажете где почитать про создание потоков, может плохо искал но в рунете не нашел:( Спасибо.


 
Digitman   (2003-01-15 14:39) [1]

TThread is an abstract class that enables creation of separate threads of execution in an application.

Unit

classes

Description

Create a descendant of TThread to represent an execution thread in a multi-threaded application. Each new instance of a TThread descendant is a new thread of execution. Multiple instances of a TThread derived class make a Delphi application multi-threaded.

When an application is run, it is loaded into memory ready for execution. At this point it becomes a process containing one or more threads that contain the data, code and other system resources for the program. A thread executes one part of an application and is allocated CPU time by the operating system. All threads of a process share the same address space and can access the process’s global variables.

Use threads to improve application performance by

Managing input from several communication devices.
Distinguishing among tasks of varying priority. For example, a high priority thread handles time critical tasks, and a low priority thread performs other tasks.

Following are issues and recommendations to be aware of when using threads:

Keeping track of too many threads consumes CPU time; the recommended limit is 16 active threads per process on single processor systems.
When multiple threads update the same resources, they must be synchronized to avoid conflicts.
Most methods that access a VCL object and update a form must only be called from within the main VCL thread or use a synchronization object such as TMultiReadExclusiveWriteSynchronizer.

To create and use a new thread object:

Choose File | New | Thread Object to create a new unit that contains an object derived from the TThread class.
Define the thread object’s Execute method by inserting the code that should execute when the thread is executed.

Note: See the Threads demo for multi-threading program samples.


 
Junior   (2003-01-15 16:45) [2]

Спасибо, но может быть есть еще примеры, попроще, с коментариями?


 
Digitman   (2003-01-15 17:48) [3]

Ты читать умеешь ?
Вот же, Борланд тебе сам пример дает :


> Note: See the Threads demo for multi-threading program samples.


Почему бы тебе не See the Threads demo прежде чем "попроще" просить ? Или там что-то непонятно, в примере от Борланда ?


 
Junior   (2003-01-15 18:11) [4]

Читать я умею, в этом примере не все понятно, я понимаю, может я тебя и злю своим ламерством, но не зря же я назвался "Junior". С вопросом частично разобрался, заготовка работает отдельно, но при использовании ее в проге, она (заготовка) не хочет обробатывать исключение. И выдает исключение по закрытию проги, пишет что неизвестное исключение от железа. Прошу относится с несхождением. Спасибо


 
gsu   (2003-01-15 20:50) [5]

посмотри пример:
C:\Program Files\Borland\Delphi6\Demos\Threads\thrddemo.dpr
или
$(DELPHI)\Demos\Threads\thrddemo.dpr (-:|~
Там все понятно


 
Digitman   (2003-01-16 08:25) [6]


> Junior



> при использовании ее в проге, она (заготовка) не хочет
> обробатывать исключение. И выдает исключение по закрытию
> проги, пишет что неизвестное исключение от железа


Приводи свой код (на основе "заготовки") - будем разбираться, что там к чему


 
Junior   (2003-01-16 10:30) [7]

>Digitman
Спасибо, выход из ситуации найден, и причина такова: машинально и не думая использовал 1 и тот же ресурс для записи и чтения двумя потоками сразу, как говорится первый блин комом:) Всем большое спасибо:)"



Страницы: 1 вся ветка

Форум: "Сети";
Текущий архив: 2003.03.06;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.008 c
1-17121
SiD_
2003-02-21 17:36
2003.03.06
Cортировка файлов и папок


3-16916
Arick
2003-02-15 22:31
2003.03.06
Документация для чайников


1-17186
Николай Быков
2003-02-24 12:02
2003.03.06
как можно быстрее сделать?


3-16896
kalliopiy
2003-02-14 16:23
2003.03.06
Сортировка


14-17293
Sorm
2003-02-07 16:09
2003.03.06
Нужен компонент позвол. замораживать столбцы





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский