Calling function within class.

frame frame86 at live.com
Wed Nov 18 18:24:59 UTC 2020


On Wednesday, 18 November 2020 at 17:55:36 UTC, Vino wrote:

>
>   I made the changes as below , still not working
>
> auto fltask = task!listFile(st);
> to
> auto fltask = task!({listFile(st);})(this).executeInNewThread();

The syntax is just wrong:

auto fltask = task!({listFile(st);})(this).executeInNewThread();

Should be:

auto fltask = task!((GetDirlist 
obj){obj.listFile(st);})(this).executeInNewThread();

It's the anonymous function syntax in one line compressed - it's 
equal to:

auto fltask = task!(
   function(GetDirlist obj) {
      obj.listFile(st);
   }
)(this).executeInNewThread();


But with your context it must look like this:

auto fltask = task!(
   function(GetDirlist obj, string foo) {
      obj.listFile(foo);
   }
)(this, st);

Still your code need to be fixed at lot to get working.


More information about the Digitalmars-d-learn mailing list