タグ付けされた質問 「kotlin-native」

3
withTimeout関数でIllegalStateExceptionが発生する:イベントループはありません。runBlocking {…}を使用して開始します。Kotlin Multiplatform iOSクライアント
更新:最初にタイムアウトなしでコルーチンを実行し、次にwithTimeoutを実行すると機能します。しかし、最初にwithTimeoutコルーチンを実行すると、エラーが発生します。同じことが非同期にも当てはまります。 私はktorを使用してAPI呼び出しを実行するデモのkotlinマルチプラットフォームアプリケーションを作成しています。コルーチンレベルでwithTimeoutを使用しているので、ktorリクエストに構成可能なタイムアウト関数を設定したいと思います。 ネットワークAPIを使用した関数呼び出しを次に示します。 suspend fun <T> onNetworkWithTimeOut( url: String, timeoutInMillis: Long, block: suspend CoroutineScope.() -> Any): T { return withTimeout(timeoutInMillis) { withContext(dispatchers.io, block) } as T } suspend fun <T> onNetworkWithoutTimeOut(url: String, block: suspend CoroutineScope.() -> Any): T { return withContext(dispatchers.io, block) as T } iOSMainモジュールのAppDispatcherクラスを次に示します。 @InternalCoroutinesApi actual class AppDispatchersImpl …
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.