Forum > General

Dereferencing an object handed into a thread by Pointer

<< < (2/3) > >>

TRon:

--- Quote from: RedOctober on November 28, 2024, 10:54:00 pm ---I think I've got it now.  I just had to change this last thing, using the modified code shown above:



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---      ARequest.Isolate(@GetAllDashItems_ISO, ISO_Parms); 
Seems the last parameter must not be a pointer, only the first one.

--- End quote ---
Both are pointers but how to indicate depends on the compiler mode (because first pointer is a pointer to a function (technically the address of the function) ). The second pointer can be anything you want to, in your case a pointer (technically in this case the address of the class instance) to a class.

PS: it might perhaps help to have a look at the help of the isolate method.

cdbc:
Hi
This seems correct:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---     ARequest.Isolate(@GetAllDashItems_ISO, ISO_Parms);...and this usage Needs a bit:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure GetAllDashItems_ISO(ARequest: TBrookHTTPRequest; AResponse: TBrookHTTPResponse; AUserData: Pointer);var   liso: TISO_Parms; ///// (l)ocal(iso) var /////begin///// here typecast to a (l)ocal(iso) variable ////////// reason for the 'FUserData' we find in: ////////// 'TBrookHTTPReqIsolatedProcHolder<T>.Create' //////  liso:= TISO_Parms(ARequest.FUserData); /// copied in isolate() ///// below we then use the local varible /////  GetAllDashItemsIsolated(ARequest, AResponse,    liso.seg_txt_rbi,    liso.req_lst,    liso.rsp_lst,    liso.fli_lst,    liso.flo_lst,    liso.sys_err,    liso.sys_err_txt,    liso.db_data_rqrd);///// behind the scenes a TObject is just an elaborate pointer /////end;I think that should do it...
Regards Benny

cdbc:
Hi
I changed my post a few times after, beware...
Regards Benny

RedOctober:
Hi cdbc,

Should I be .Free ing the local instance of liso, like this...


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  ...   liso:= TISO_Parms(ARequest.FUserData);   GetAllDashItemsIsolated(ARequest, AResponse,    liso.seg_txt_rbi,    liso.req_lst,    liso.rsp_lst,    liso.fli_lst,    liso.flo_lst,    liso.sys_err,    liso.sys_err_txt,    liso.db_data_rqrd);     liso.Free; ...  


or will the isolated thread free itself, and everything in it, when it completes?

cdbc:
Hi
H*LL NO, no freeing, you are just borrowing it!!!!
The freeing takes place outside of the thread, in the thread you created it  in(possibly the main thread)...
I will add, that the others are right, it's more difficult for us, with only a few bits of code...
Regards Benny

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version