Re: How can execute method in new Thread?

2020-11-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 14 November 2020 at 17:21:15 UTC, Marcone wrote: Error: D:\dmd2\windows\bin\..\..\src\phobos\std\parallelism.d(516): Error: struct `Fruit` does not overload () I think you need to pass the this pointer somehow. This works: import std; struct Fruit { string name;

Re: How can execute method in new Thread?

2020-11-15 Thread frame via Digitalmars-d-learn
On Saturday, 14 November 2020 at 17:21:15 UTC, Marcone wrote: Error: D:\dmd2\windows\bin\..\..\src\phobos\std\parallelism.d(516): Error: struct `Fruit` does not overload () You can't. Because everything that can run in a new thread must be a (separate) function. If you are using an object

How can execute method in new Thread?

2020-11-14 Thread Marcone via Digitalmars-d-learn
My simple example code: import std; struct Fruit { string name; this(string name){ this.name = name; } void printmyname(){ writeln(this.name); } void showname(){ task!this.printmyname().executeInNewThread(); //