小编Myr*_*SC2的帖子

在windows cmd的子目录中运行命名.exe

我对这个问题感到愚蠢,但是这里有.在linux/mac中,只需编写其名称即可在shell中运行可执行文件.你能在windows命令行中做类似的事情吗?

示例:我在目录中dir.我想a.exedir/subdir不更改目录subdir或写入的情况下运行文件subdir/a.exe.这可能吗?

cmd

7
推荐指数
2
解决办法
1万
查看次数

通过 Key 类访问 CoroutineContext 元素

在 Ktor 中,我希望实现某种方法来引用 coroutineContext 内的键值对,而无需在方法参数中拖动对对象的引用。基于https://proandroiddev.com/demystifying-coroutinecontext-1ce5b68407ad我编写了我的参考类:

class MyElement(override val key: CoroutineContext.Key<*>, val value: String) : CoroutineContext.Element
class MyKey: CoroutineContext.Key<MyElement>
Run Code Online (Sandbox Code Playgroud)

... // 内部路由:

val key: CoroutineContext.Key<MyElement> = MyKey()
val ele = MyElement(key, "myJWT")
withContext(coroutineContext + ele) {
    val notNullEle : MyElement = coroutineContext[ele.key] as MyElement // not null
    logger.info(notNullEle.value) // "myJWT"
    val shouldNotBeNullEle = coroutineContext[MyKey()]// NULL!
}
val shouldBeNull = coroutineContext[ele.key] // is and should be null
val shouldBeNull2 = coroutineContext[MyKey()] // is and should also be null
Run Code Online (Sandbox Code Playgroud)

当我发送ele.key …

kotlin ktor kotlin-coroutines

1
推荐指数
1
解决办法
1629
查看次数

标签 统计

cmd ×1

kotlin ×1

kotlin-coroutines ×1

ktor ×1