Skip to content

CS4014 warning when returning ValueTask instead of Task #2508

Open
@BramMusters

Description

@BramMusters

Description

Hangfire throws CS4014 compilation warning when enqueuing async jobs that return ValueTask instead of Task.

Steps to Reproduce

Working case with Task:

public async Task ProcessDataAsync_Task(int id)
{
    // Async operation
    await Task.Delay(100);
    // Process data
}

// Works fine, builds successfully
BackgroundJob.Enqueue(() => ProcessDataAsync_Task(123));

Failing case with ValueTask:

public async ValueTask ProcessDataAsync_ValueTask(int id)
{
    // Async operation
    await Task.Delay(100);
    // Process data
}

// Compiler warning CS4014
BackgroundJob.Enqueue(() => ProcessDataAsync_ValueTask(123));

Expected Behavior

Hangfire should support enqueuing methods that return ValueTask just as it supports methods that return Task, without throwing CS4014 compilation errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions