我正在努力研究如何在表单之间传递值.我有四种形式,我想将由Login第四和最终形式检索到的信息传递给我.
这就是我到目前为止所拥有的.
在这个功能:
private void btnLogin_Click(object sender, EventArgs e)
Run Code Online (Sandbox Code Playgroud)
我已经反序列化了我想要的数据:
NewDataSet resultingMessage = (NewDataSet)serializer.Deserialize(rdr);
Run Code Online (Sandbox Code Playgroud)
然后,当我打电话给下一个表格时,我已经这样做了:
Form myFrm = new frmVoiceOver(resultingMessage);
myFrm.Show();
Run Code Online (Sandbox Code Playgroud)
然后,我的VoiceOver表单看起来像这样:
public frmVoiceOver(NewDataSet loginData)
{
InitializeComponent();
}
private void btnVoiceOverNo_Click(object sender, EventArgs e)
{
this.Close();
Form myFrm = new frmClipInformation();
myFrm.Show();
}
Run Code Online (Sandbox Code Playgroud)
当我调试时,我可以看到数据处于loginData第二种形式,但我似乎无法在btnVoiceOverNo_Click事件中访问它.我如何访问它以便将其传递给下一个表单?
我std::async在实际代码中使用它之前进行了单独测试,以验证它在我的平台上是否正常工作(这是ubuntu 12.10 64位).
它工作(有点很少),通常只是挂起.如果它适合你,不要妄下结论.再尝试几次,它可能会挂起.
如果我删除了pthread_mutex测试,它就不会挂起.这是我可以重现挂起的最小代码.有什么理由不能将C pthread代码与c ++异步代码混合使用吗?
#include <iostream>
#include <pthread.h>
#include <chrono>
#include <future>
#include <iomanip>
#include <sstream>
#include <type_traits>
template<typename T>
std::string format_ns(T &&value)
{
std::stringstream s;
if (std::is_floating_point<T>::value)
s << std::setprecision(3);
if (value >= 1000000000)
s << value / 1000000000 << "s";
else if (value >= 1000000)
s << value / 1000000 << "ms";
else if (value >= 1000)
s << value / 1000 << "us";
else
s << value << "ns";
return s.str();
} …Run Code Online (Sandbox Code Playgroud) 我正在查看我的一些较旧的代码,并且看到了使用指针来实现Variant对象树的代码。它是一棵树,因为每个树都Variant可以包含一个unordered_mapof Variant*。
我查看了代码,想知道为什么不只使用值、 astd::vector<Variant>和std::unordered_map<std::string, Variant>, 而不是Variant*.
所以我继续改变它。除了一件事,似乎还可以,我遇到了错误:
Run Code Online (Sandbox Code Playgroud)/usr/local/include/c++/6.1.0/bits/stl_pair.h:153:11: error: 'std::pair<_T1, _T2>::second' has incomplete type _T2 second; /// @c second is a copy of the second object ^~~~~~ main.cpp:11:8: note: forward declaration of 'struct Variant' struct Variant ^~~~~~~
所以我想我可以欺骗编译器延迟了解该类型的需要,这也不起作用。
我以为这更早有效,但实际上并没有,我忘记::type了using HideMap...
#include <vector>
#include <unordered_map>
#include <iostream>
template<typename K, typename V>
struct HideMap
{
using type = …Run Code Online (Sandbox Code Playgroud) c++ templates forward-declaration c++-standard-library c++14