c# - 如何传递 byte[] 数据并从客户端获取响应?
问题描述
我有字节 [] 数据和代码形式的图像,用于传递字节数据以获取客户端的响应。我需要帮助把它们放在一起
我尝试在我有字节数据的地方使用代码,但是异步操作造成了很多混乱
"data" 包含 byte[] 数据
private async void InitializeVideoFeedModule()
{
//Must in UI thread
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
//Raw data and decoded data listener
if (videoParser == null)
{
videoParser = new DJIVideoParser.Parser();
videoParser.Initialize( delegate (byte[] data)
{
return DJISDKManager.Instance.VideoFeeder.ParseAssitantDecodingInfo(0, data);
});
}
}
}
传递字节数据并获得响应的代码
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Prediction-Key", "XXXXX");
// Prediction URL - replace this example URL with valid Prediction URL.
string sequenceURL = "https://abc/dcr/xyz";
HttpResponseMessage response;
using (var content = new ByteArrayContent(data))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response = await client.PostAsync(sequenceURL, content);
var output = await response.Content.ReadAsStringAsync();
Console.WriteLine(output);
JObject json = JObject.Parse(output);
}
当我一起使用委托对象和异步操作时,它们会导致冲突。
解决方案
推荐阅读
- sql - 为什么忽略 SQL Server 2014 中的空格文本
- java - 为什么图片是黑色的?
- javascript - 我在一页中有 3 个数据表,我需要在每个表中选择一个
- c# - Parallel.ForEach() 是否在执行后立即销毁线程?
- javascript - doc.fromHTML 不是函数
- reactjs - 反应中的千位分隔符输入类型数(JSX)
- c - 如何处理 SIGSEGV,Segmentation fault。使用 Avx2 时
- django - “rest_framework CSRF token failed”,但它已经在请求标头中设置为“X-CSRF-Token”
- elasticsearch - elasticdump安装问题:async _loop Unexpected identifier error
- ios - ipa 文件的校验和