wpf ObjectDataProvider与静态类中的枚举

时间:2016-12-05 10:04:15

标签: wpf xaml enums

我的枚举在vb.net中的模块中(等于C#中的Static类)

int called_from_async(std::string taskName, int creationTime, int& itv_duration, int itv_start, bool& cancel)
{
    bool bExit = false;
    bool bStart = false;
    while (!bExit && !cancel)
    {
        if (creationTime > itv_start && !bStart)
        {
            bStart = true;
        }

        creationTime++;

        if (bStart)
        {
            if (--itv_duration < 0)
            {
                bExit = true;
            }
        }

        std::this_thread::sleep_for(std::chrono::seconds(1));
    }

    std::cout << taskName << std::endl;

    return 1;
}

class eventManager
{
    public:
    eventManager() { };
    ~eventManager() { };

    std::future<int> addTask(std::string taskName, int creationTime, int& itv_duration, int itv_start, bool& cancel)
    {
        return std::async(std::launch::async, [=, &itv_duration, &cancel]() { return called_from_async(taskName, creationTime, itv_duration, itv_start, cancel); });
    }
};

int main()
{

    std::vector<std::future<int>> futures; // place for asyns tasks

    eventManager evtManager;

    bool cancel1 = false, cancel5 = false;
    int shortDuration = 2, longDuration = 360;
    futures.push_back(std::move(evtManager.addTask("Task 1", 1234560, shortDuration, 1234570, cancel1))); // will be done as 4th
    //...
    futures.push_back(std::move(evtManager.addTask("Task 5", 1234560, longDuration, 1234570, cancel5))); // super long task, but will be done as zero because of cancel event.

    longDuration = 1;
    //cancel5 = true;

    //wait for your tasks to finish, so that references are valid
    //or declare them in the higher scope

    return 0;
}

这就是资源

Public Module EtatAffaire
    Public Enum EtatAffaireEnum As Integer
        Undefined = 0
        Encours = 1
        Receptionnee = 2
        Cloturee = 3
        Facturee = 4
        ClotureeFacturee = Cloturee + Facturee
    End Enum
...

说“EtatAffaireEnum无法访问或无法重新启动”。

你有什么想法吗?

1 个答案:

答案 0 :(得分:2)

提供的方法参数不正确。 Enum.GetValues期望Type参数

<ObjectDataProvider.MethodParameters>
    <x:Type TypeName="model:EtatAffaire+EtatAffaireEnum"/>
</ObjectDataProvider.MethodParameters>

嵌套类型名称由+加入(请参阅此question