task

How can I wrap this Powershell cmdlet into a timeout function?

与世无争的帅哥 提交于 2021-01-29 07:00:44
问题 I've tried (and failed) to get [System.Delegate]::CreateDelegate( to work, New-Object [System.Threading.Tasks.Task]::Run(, to work, Start-Job with Wait-Job, Powershell does not seem to be setup to do an asynchronous task with a wait timeout? If anyone has any ideas, that'd be awesome. do { Sleep 2; $testShare = Test-Path "\\$server\c$"; Write-Host "Share availability is:" $testShare; }while($testShare -eq $true) # wait for the share to become unavailable Adams suggestion do { Sleep 1; #

415 Status When Passing Model into Controller Action in ASP.NET Core 3.1 MVC

瘦欲@ 提交于 2021-01-29 05:31:03
问题 I've seen many tutorials and documentation pass the model as an argument in an Action in a controller. Every time I do this I get a 415 status error (incorrect media type) when the action is called. This is problematic for me because my fields clear after the action occurs. Many have suggested calling the model when I return the View, but that has not been working for me. Does anyone know why that is and how I can fix it? I'm so frustrated I've tried so many things and it just never works :(

Is ConcurrentDictionary.GetOrAdd truly thread-safe?

核能气质少年 提交于 2021-01-29 02:41:18
问题 I have this piece of code where I want to await on a ongoing task if that task was created for the same input. Here is minimal reproduction of what I'm doing. private static ConcurrentDictionary<int, Task<int>> _tasks = new ConcurrentDictionary<int, Task<int>>(); private readonly ExternalService _service; public async Task SampleTask(){ var result = await _service.DoSomething(); await Task.Delay(1000) //this task takes some time do finish return result; } public async Task<int> DoTask(int key

Grouping/inheriting properties for tasks in Gradle

北城余情 提交于 2021-01-28 12:11:04
问题 Is there a way to reuse property groups in Gradle? Something that would look like: def propGroup = [ options.fork = true options.forkOptions.executable = ... ] task compileThis(type:JavaCompile) { options.fork = propGroup.options.fork options.forkOptions.setExecutable(propGroup.options.forkOptions.executable) destinationDir = file(xxx) } task compileThat(type:JavaCompile) { options.fork = propGroup.options.fork options.forkOptions.setExecutable(propGroup.options.forkOptions.executable)

How to configure a VSCode Task to run a powershell script in the integrated terminal

纵饮孤独 提交于 2021-01-28 10:40:44
问题 In such a way that it is not in a sub shell. I need it to be able to prepare the environment...set environment variable. "version": "0.1.0", "command": "${workspaceFolder}/Invoke-Task.ps1", /*"command": "powershell", creates subshell so doesn't work*/ "isShellCommand": false, "args": [], "showOutput": "always", "echoCommand": true, "suppressTaskName": true, "tasks": [ { "taskName": "task1", "args": ["task1"] }, { "taskName": "task2", "args": ["task2"] } ] 回答1: This has been doable since 2017,

Execute and wait for multiple parallel and sequential Tasks by using a Arraylist of Tasks in JavaFX

我怕爱的太早我们不能终老 提交于 2021-01-28 09:36:30
问题 I'm looking for a suitable way to display the processing time of parallel running Tasks on a separate stage. I want to execute different tasks combined in an ArrayList - one after the other. For this case I'm using a ThreadPool. After each executed list, I want to wait until all tasks are completed. Only when the tasks have reached the status „succeeded“, I want to do something in the MainThread. After that I want to execute another list of tasks and visualize them on a separate stage as well

Should I use ConfigureAwait(false) in places like Repository?

£可爱£侵袭症+ 提交于 2021-01-28 09:14:55
问题 Just read this article about ConfigureAwait and it made me think on an issue I haven't been able to come to peace with for some time now. Consider the code below. Each dependency uses await to make the call asynchronous. My concern is that each time we exit an await it goes back to the UI thread and I don't want that until I'm actually at the top level where the UI needs to be updated in order to reduce thread context switching. That made me think that ConfigureAwait(false) should be used in

Should I use ConfigureAwait(false) in places like Repository?

*爱你&永不变心* 提交于 2021-01-28 09:10:58
问题 Just read this article about ConfigureAwait and it made me think on an issue I haven't been able to come to peace with for some time now. Consider the code below. Each dependency uses await to make the call asynchronous. My concern is that each time we exit an await it goes back to the UI thread and I don't want that until I'm actually at the top level where the UI needs to be updated in order to reduce thread context switching. That made me think that ConfigureAwait(false) should be used in

Android kotlin task to be executed using coroutines

岁酱吖の 提交于 2021-01-28 09:00:56
问题 As an example, I'm using FusedLocationProviderClient to access the current location, which returns a task which callback will eventually return the location. The method looks something like follows: fun getLocation(callback: MyCallback){ val flpc = LocationServices.getFusedLocationProviderClient(it) flpc.lastLocation.addOnSuccessListener { callback.onLocation(it) } } Is it possible to transform this so that I can use corroutines to suspend this function and wait for the task returned by flpc

Task based vs. thread based Watchdog - but async needed

断了今生、忘了曾经 提交于 2021-01-28 06:13:32
问题 We're using watchdogs to determine whether a connected system is still alive or not. In the previous code we used TCP directly and treated the watchdog in a separate thread. Now is a new service used that provides it's data using gRPC. For that we tried using the async interface with tasks but a task based watchdog will fail. I wrote a small DEMO that abstracts the code and illustrates the problem. You can switch between task based watchdog and thread based watchdog by commenting out line 18