来自非管理世界的C#结构能否“实时” - 更新?(Can C# structs coming from the unmanaged world be “live”-updating?)
假设我从非托管库获取一个指向结构的
IntPtr
指针。 有没有办法,在C#中,从这个指针获取一个“实时”结构,这样如果我做一个修改非托管结构的调用,我的“实时”结构会立即反映出来吗?我相信标准方法是使用编组来构造数据的副本,由于各种原因(结构布局,数据类型兼容性,不驻留在.NET托管内存中),这样就不能像这样“实时”。 但我找不到任何明确的确认,在C#中不可能使用“实时”结构。 是吗?
在没有使用C ++ / CLI的情况下,我最接近这种“实时”结构的是什么?
Suppose I get an
IntPtr
pointer to a struct from an unmanaged library. Is there any way, in C#, to obtain a "live" struct from this pointer, so that if I make a call that modifies the unmanaged struct, my "live" struct reflects this immediately?I believe the standard approach is to construct a copy of the data using marshalling, which can't be "live" like this for various reasons (struct layout, data type compatibility, not residing in the .NET managed memory). But I couldn't find any explicit confirmation that "live" structs are impossible in C# though. Are they?
What's the closest I can get to such "live" structs without going to C++/CLI?
原文:https://stackoverflow.com/questions/7956355
最满意答案
http://developer.android.com/reference/android/os/AsyncTask.html 。 查看标题The 4 steps下的主题。
您正在获取Toast的NullPointerException。 如果你从MainActivity调用asynctask那么
尝试
Toast.makeText(MainActivity.this, "Podaci uspešno preuzeti", Toast.LENGTH_SHORT).show();
您应该将活动上下文,文本和持续时间作为参数传递给makeText。
OR
根据Eng.Fouad的建议,你的dl为null。
http://developer.android.com/reference/android/os/AsyncTask.html. Look at the topic under heading The 4 steps.
You are getting NullPointerException for the Toast. If you calling asynctask from say MainActivity then
Try
Toast.makeText(MainActivity.this, "Podaci uspešno preuzeti", Toast.LENGTH_SHORT).show();
Your should pass activity context,your text and duration as parameters to makeText.
OR
As suggested by Eng.Fouad your dl is null.
相关问答
更多-
关于onPostExecute任务(About task onPostExecute)[2023-01-06]
你没有在onPostExecute上调用权利: 你需要: @Override protected void onPostExecute(ArrayListdata) { super.onPostExecute(data); progress.dismiss(); } 问题是你没有通过添加onPostExecute()来覆盖AsyncTask类中的方法。 您需要添加@Override注释并传入AsyncTask类的返回类型。 祝你好运,快乐的编码! your not ca ... -
您可以在下面显示哪个可以解决您的问题公共类背景扩展AsyncTask { private ProgressDialog dialog; private ConnectivityManager cm; String jsonurl, jsonstring; mobile_form mform; private mContext context; public background (Context ctx){ this.mContext = ctx; this.cm = (Connecti ...
-
onPostExecute不被调用(onPostExecute is not called)[2022-01-21]
看起来你错过了一些东西 @Override protected void onPostExecute(Void result) { super.onPostExecute(result); if (exception.contains("java.net.UnknownHostException")) { MainActivity.showDialog(); Log.i("Error Message", "ERROR MESSAGE SHOWN"); ... -
在这里,一般来说这是如何工作的。 这是基于此答案并修改为特定于您现有的代码。 基本上根据用户输入的内容分配您的成员变量,并将该值与您从服务器获得的值进行比较: public class MyClass extends Activity { //member variable for the username the user enters: User userEnteredUser; public class FetchUserDataAsyncTask extends AsyncTask< ...
-
你永远不应该自己实例化一个活动。 正确的方法是通过意图将所需数据传递给新活动: @Override protected void onPostExecute(String s) { super.onPostExecute(s); Intent intent = new Intent(CurrentActivity.this, Answer.class); intent.putExtra("MY_DATA", s); startActivity(intent); } 然后在您的答案活 ...
-
OnPostExecute被跳过(OnPostExecute is skipped)[2024-02-23]
当你在AsyncTask上调用.get()时,它强制它被称为同步。 在这种情况下,在主线程上。 这是不允许的。 所以AsyncTask进入doInBackground,然后Android系统立即抛出一个错误。 如果你看看你的LogCat,错误将被打印在那里。 您需要从AsyncTask中移除.get(),并实际处理异步。 When you call .get() on an AsyncTask, it forces it to be called synchronous. Which in this cas ... -
onPostExecute没有运行(onPostExecute not running)[2022-06-30]
你对线程的工作方式有误解。 您正在使用异步调用,然后忙着等待它完成。 // --- TEST ASYNC STATUS --- while(dit != null) { if(dit.getStatus() == AsyncTask.Status.FINISHED) { Log.i("ASYNC", "END2!!"); break; } else { Log.w("ASYNC WAITING", dit.getStatus().to ... -
http://developer.android.com/reference/android/os/AsyncTask.html 。 查看标题The 4 steps下的主题。 您正在获取Toast的NullPointerException。 如果你从MainActivity调用asynctask那么 尝试 Toast.makeText(MainActivity.this, "Podaci uspešno preuzeti", Toast.LENGTH_SHORT).show(); 您应该将活动上下文, ...
-
更改doInBackGround返回null为: try { return new JSONObject(reusults); } catch (Throwable t) { return null; } Change on doInBackGround return null to: try { return new JSONObject(reusults); } catch (Throwable t) { return null; }
-
检查一下 @Override protected void onPostExecute(List
results) { super.onPostExecute(results); if(results.size()>0){ for(int i=0;i 相关文章
更多- [转] C#开源项目大全
- Solr4:Hello World级别示范
- 微信C#响应代码
- C#开发微信门户及应用(4)--关注用户列表及详细信息管理
- C#开发微信门户及应用(3)--文本消息和图文消息的应答
- C#开发微信门户及应用(1)--开始使用微信接口
- C#开发微信门户及应用(10)--在管理系统中同步微信用户分组信息
- C#开发微信门户及应用(8)-微信门户应用管理系统功能介绍
- 转 C#开发微信门户及应用(1)--开始使用微信接口
- C#开发微信门户及应用(1)--开始使用微信接口
最新问答
更多- 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
- 如何打破按钮上的生命周期循环(How to break do-while loop on button)
- C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
- 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
- 如何并排放置两个元件?(How to position two elements side by side?)
- 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
- 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
- Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
- 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
- 电脑高中毕业学习去哪里培训
- 电脑系统专业就业状况如何啊?
- IEnumerable
linq表达式(IEnumerable linq expressions) - 如何在Spring测试中连接依赖关系(How to wire dependencies in Spring tests)
- Solr可以在没有Lucene的情况下运行吗?(Can Solr run without Lucene?)
- 如何保证Task在当前线程上同步运行?(How to guarantee that a Task runs synchronously on the current thread?)
- 在保持每列的类的同时向数据框添加行(Adding row to data frame while maintaining the class of each column)
- 的?(The ? marks in emacs/haskell and ghc mode)
- 一个线程可以调用SuspendThread传递自己的线程ID吗?(Can a thread call SuspendThread passing its own thread ID?)
- 延迟socket.io响应,并“警告 - websocket连接无效”(Delayed socket.io response, and “warn - websocket connection invalid”)
- 悬停时的图像转换(Image transition on hover)
- IIS 7.5仅显示homecontroller(IIS 7.5 only shows homecontroller)
- 没有JavaScript的复选框“关闭”值(Checkbox 'off' value without JavaScript)
- java分布式框架有哪些
- Python:填写表单并点击按钮确认[关闭](Python: fill out a form and confirm with a button click [closed])
- PHP将文件链接到根文件目录(PHP Linking Files to Root File Directory)
- 我如何删除ListView中的项目?(How I can remove a item in my ListView?)
- 您是否必须为TFS(云)中的每个BUG创建一个TASK以跟踪时间?(Do you have to create a TASK for every BUG in TFS (Cloud) to track time?)
- typoscript TMENU ATagParams小写(typoscript TMENU ATagParams lowercase)
- 武陟会计培训类的学校哪个好点?
- 从链接中删除文本修饰(Remove text decoration from links)