On Sunday, 14 November 2021 at 16:40:58 UTC, Andrey Zherikov wrote:
Just do `auto t1 = task(&threadFunc)` in `threadCreator` then.


Error: value of `this` is not known at compile time

```D
import std.stdio;
import std.parallelism;

class TC
{
    void threadFunc()
    {
        import core.thread;
        import core.time;

        scope (exit)
            writeln("threadFunc done");

        core.thread.osthread.Thread.getThis.sleep(msecs(2000));
    }

    void threadCreator()
    {
        scope (exit)
            writeln("threadCreator done");

        auto t1 = task!(&threadFunc);
        t1.executeInNewThread();
    }
}

void main()
{
    scope (exit)
        writeln("main done");

    auto tc = new TC;
    tc.threadCreator();
}
```

Reply via email to