泛型 在 C# 中不起作用,即使运行没有任何错误

2023-12-22

我正在使用 Silverlight 5 (VS 2010) 创建一个 C# Web 应用程序。首先,我创建了控制台应用程序,一切正常。但是当我在网络应用程序中执行此操作时会出现问题。

即使在网络应用程序中,它对于特定的设置数据类型也能正常工作(例如int代替<T>它工作正常)但是当我使用通用时它不起作用。它编译没有错误但它甚至不调试设置为“切换断点”的区域。最初的 GUI 是这样的:

但是当控制权传递到容易出错的部分时,GUI突然像这样消失了

我保留断点的地方被这个替换了

(见最左边)结果我无法调试找到问题 .

一些解释我正在尝试做的事情:在下面给定的代码中,我有一个二进制文件,并存储在数据类型的“fileContents”内byte[](我不会向您透露读取该文件的方法,现在您可以认为 fileContents 包含内部二进制文件的内容MainPage班级)。实际上,我将存储符号(二进制文件中的 0 和 1 形式)并找到其频率(通过计算它在文件中重复的次数,但这没有问题,所以我不会为其编写方法)。但是这个processingValue我的代码中的变量将是通用类型(<T>)我将存储在"symbol"(这也是<T>类型(从二进制文件读取的该符号可能是以下之一short/int/long/UInt32/UInt64等)我没有在我的代码中显示)。

我有一个这样的场景:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace 
{
    public partial class MainPage: UserControl 
    {
        byte[] fileContent;
        public MainPage() 
        {
            InitializeComponent();
            fileContent = null; //Suppose it already contains binary fileContents
        }
//I press the button in order to call the Huffman class because it's Object declared in it
        public void ButtonClickEvent(object sender, RoutedEventArgs e) 
        {
            MessageBox.Show("check0");

            //Suppose i had stored contents of a file inside "fileContent" , so fileContent below contains
            //contents of a binary file
           //**THE LINE BELOW IS ERROR PRONE**
            Huffman < uint > obj1 = new Huffman < uint > (this, fileContent, BitConverter.ToUInt32);

            //This Object creation creates problem, whereas if i remove generic type (<T>), Then it works fine.
            //If i don't use genrics then i do it like this : Huffman obj1 = new Huffman(this, fileContent); (Whereas <T> in Huffman class is replaced by "int" and it works fine)

            MessageBox.Show("check1"); //This check box is never executed 
        }
    }

    public class Huffman < T > where T: struct,IComparable < T > ,IEquatable < T > 
    {
        public Huffman(MainPage Object, byte[] fileContent, Func < byte[], int, T > converter) 
        {
            MessageBox.Show("check2"); //It never executes          
            length = fileContent.Length;
            size = Marshal.SizeOf(typeof (T));
            byte[] data;
            for (long position = 0; position + size < length; position += size)
            {
                data = fileContent; //This data conatains the filecontents now
                T processingValue = converter(data, 0); 
                {
                    //I do something here with processingValue it could be int16/int32/int64/uin32/uint64 etc.
                }
            }
        }
    }
}  

有什么问题吗BitConverterMainPage 类中的对象创建函数?

我什至无法调试 Huffman 类,我在 Huffman 类的起点和终点设置了断点,但控件没有进入,并且 Internet Explorer 上的按钮(使用 XAML GUI 创建)消失了。

这是我的完整代码:(请注意我正在读取二进制文件(任何扩展名为“.o”(FileName.o)的文件都可以用来测试我的代码,我读得很好)):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace FinalSS
{
    public partial class MainPage : UserControl
    {
        public const int CHUNK_SIZE = 4096;
        public const string UPLOAD_URI = "http://localhost:50323/FileUpload.ashx?filename={0}&append={1}";
        public const string UPLOAD_DIALOG_FILTER = "All files (*.*)|*.*|Jpeg Images (*.jpg)|*.png|PNG Images (*.png)|*.png";
        private Stream data;
        private string fileName;
        private long TotalBytes;
        private long UploadedBytes;
        byte[] fileContent;
        public event Action simpleEvent;

        public MainPage()
        {
            InitializeComponent();
            progressBar.Visibility = Visibility.Collapsed;
            textBox.Visibility = Visibility.Collapsed;
           // fileContent = null;
            UploadedBytes = 0;
            TotalBytes = 0;                      
        }
     /*   public void comboInvoke()
        {
            comboBox1.Items.Add("byte");
            comboBox1.Items.Add("sbyte");
            comboBox1.Items.Add("short");
            comboBox1.Items.Add("int");
            comboBox1.Items.Add("long");
        }   */


        public void BrowseButtonClick(object sender, RoutedEventArgs e)
        {   OpenFileDialog dlg = new OpenFileDialog();
            dlg.Multiselect = false;
            dlg.Filter = UPLOAD_DIALOG_FILTER;
            bool? retVal = dlg.ShowDialog();

            if (retVal != null && retVal == true)
            {
                progressBar.Visibility = Visibility.Visible;
                textBox.Visibility = Visibility.Visible;
                textBox.Text = "Uploading the file...";

                data = dlg.File.OpenRead();
                TotalBytes = data.Length;
                UploadedBytes = 0;
                fileName = dlg.File.Name;
                progressBar.Maximum = TotalBytes;
                UploadFileChunk();
            }            
        }

        private void UploadFileChunk()
        {
            textBox.Text = "Upload in progress...";
            string uploadUri = "";
            if (UploadedBytes == 0)
            {
                uploadUri = String.Format(UPLOAD_URI, fileName, 0); // Dont't append
            }
            else if (UploadedBytes < TotalBytes)
            {
                uploadUri = String.Format(UPLOAD_URI, fileName, 1); // append
            }
            else
            {
                return;  // Upload finished
            }

            fileContent = new byte[CHUNK_SIZE];
            int bytesRead = data.Read(fileContent, 0, CHUNK_SIZE);
            data.Flush();

            WebClient wc = new WebClient();
            wc.OpenWriteCompleted += new OpenWriteCompletedEventHandler(wc_OpenWriteCompleted);
            Uri u = new Uri(uploadUri);
            wc.OpenWriteAsync(u, null, new object[] { fileContent, bytesRead });
            UploadedBytes += fileContent.Length;
            MessageBox.Show("check0");
            Huffman<uint> obj1 = new Huffman<uint>(this, fileContent, BitConverter.ToUInt32);
            MessageBox.Show("check1");
        }
        void wc_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e)
        {
            progressBar.Value = UploadedBytes;
            if (e.Error == null)
            {
                object[] objArr = e.UserState as object[];
                byte[] fileContent = objArr[0] as byte[];
                int bytesRead = Convert.ToInt32(objArr[1]);
                Stream outputStream = e.Result;
                outputStream.Write(fileContent, 0, bytesRead);
                outputStream.Close();

                if (UploadedBytes < TotalBytes)
                {
                    UploadFileChunk();
                }
                else
                {
                    textBox.Text = fileName;
                }
            }

        }
        /// <summary>
        /// ///////////////////////////////////////////////////////
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void ShowButtonClick(object sender, RoutedEventArgs e)
        {
            if (simpleEvent != null) simpleEvent();
        }

        private void CompressButtonClick(object sender, RoutedEventArgs e)
        {

        }

        private void CloseButtonClick(object sender, RoutedEventArgs e)
        {

        }

        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void textBox_TextChanged(object sender, TextChangedEventArgs e)
        {

        }

        private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {

        }

        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void listBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void TreeViewItem_Selected_1(object sender, RoutedEventArgs e)
        {

        }

        private void TreeViewItem_Selected(object sender, RoutedEventArgs e)
        {

        }
    }

    public class Huffman<T> where T : struct, IComparable<T>, IEquatable<T> 
    {        
       long length;
       int size;
       byte[] data;
        public class Node
        {
            public Node next, left, right;
            public T symbol;   // This symbol is of generic type.
            public int freq;
            public int is_processed;

        }
        public Node front, rear;
        public Huffman(MainPage form, byte[] fileContent,Func < byte[], int, T > converter)
        {
           MessageBox.Show("check2");
            //    form.simpleEvent += () => ShowClick(form,fileContent);
           length = 0;
            front = null;
            rear = null;
            MessageBox.Show("check4");
            length = fileContent.Length;
            size = Marshal.SizeOf(typeof(T));
            Stream stream = new MemoryStream(fileContent);
            {
                for (long position = 0; position + size < length; position += size)
                {
                    data = fileContent;
                    T processingValue = converter(data, 0);
                    {
                        Node pt, temp;
                        bool is_there = false;
                        pt = front;
                        while (pt != null)
                        {
                            form.listBox1.Visibility = Visibility.Visible;
                            if (pt.symbol.Equals(processingValue))
                            {
                                pt.freq++;
                                is_there = true;

                                break;
                            }
                            temp = pt;
                            pt = pt.next;
                        }
                        if (is_there == false)
                        {
                            temp = new Node();
                            temp.symbol = processingValue;
                            temp.freq = 1;
                            temp.left = null;
                            temp.right = null;
                            temp.next = null;
                            temp.is_processed = 0;
                            if (front == null)
                            {
                                front = temp;
                            }
                            else
                            {
                                temp.next = front;
                                front = temp;
                            }
                        }
                    }
                }
                stream.Close();
            }

            MessageBox.Show("Yes correctly done");
            merge_sort(front);
            Print_tree(front, form);
        }
         public Node merge_sort(Node head)
         {
             if (head == null || head.next == null)
             {
                 return head;
             }
             Node middle = getMiddle(head);
             Node sHalf = middle.next;
             middle.next = null;
             return merge(merge_sort(head), merge_sort(sHalf));
         }
         public Node merge(Node a, Node b)
         {
             Node dummyHead, curr;
             dummyHead = new Node();
             curr = dummyHead;
             while (a != null && b != null)
             {
                 if (a.freq <= b.freq)
                 {
                     curr.next = a;
                     a = a.next;
                 }
                 else
                 {
                     curr.next = b;
                     b = b.next;
                 }
                 curr = curr.next;
             }
             curr.next = (a == null) ? b : a;
             return dummyHead.next;
         }
         public Node getMiddle(Node head)
         {
             if (head == null)
             {
                 return head;
             }
             Node slow, fast;
             slow = fast = head;
             while (fast.next != null && fast.next.next != null)
             {
                 slow = slow.next;
                 fast = fast.next.next;
             }
             return slow;
         }
       ///////
         public void Print_tree(Node treee,MainPage obj)
         {
             Node pt = treee;
             while (pt != null)
             {
                 obj.listBox1.Items.Add("Symbol :" + pt.symbol + " -" + " Frequency : " + pt.freq);
                 //  Debug.WriteLine("Symbol :" + pt.symbol + " -" + " Frequency : " + pt.freq);
                 pt = pt.next;
             }
         }

   }
}

这是 xml 代码:

<UserControl x:Class="FinalSS.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
              xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    d:DesignHeight="300" d:DesignWidth="400" Loaded="UserControl_Loaded">

<Grid x:Name="LayoutRoot" Background="Wheat" Visibility="Visible" Height="348" Width="681">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="37*" />
            <ColumnDefinition Width="86*" />
            <ColumnDefinition Width="558*" />
        </Grid.ColumnDefinitions>
        <sdk:TreeView SelectedItemChanged="TreeView_SelectedItemChanged" Margin="12,12,12,41" Background="wheat" Grid.ColumnSpan="3">
            <sdk:TreeViewItem Header="File" Selected="TreeViewItem_Selected" >
                <sdk:TreeViewItem.Items>
                    <sdk:TreeViewItem Selected="TreeViewItem_Selected_1">
                        <sdk:TreeViewItem.Header>
                            <StackPanel Orientation="Horizontal" >
                                <Button Content="Browse File"  Width="76" Height="20" Click="BrowseButtonClick"></Button>
                            </StackPanel>
                        </sdk:TreeViewItem.Header>
                    </sdk:TreeViewItem>
                    <sdk:TreeViewItem Selected="TreeViewItem_Selected_1">
                        <sdk:TreeViewItem.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Content="Show Data" Width="75" Height="20" Click="ShowButtonClick"></Button>
                            </StackPanel>
                        </sdk:TreeViewItem.Header>
                    </sdk:TreeViewItem>
                    <sdk:TreeViewItem Selected="TreeViewItem_Selected_1">
                        <sdk:TreeViewItem.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Content="Compress" Width="75" Height="20" Click="CompressButtonClick"></Button>
                            </StackPanel>
                        </sdk:TreeViewItem.Header>
                    </sdk:TreeViewItem>
                    <sdk:TreeViewItem Selected="TreeViewItem_Selected_1">
                        <sdk:TreeViewItem.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Content="close"   Width="75" Height="20" Click="CloseButtonClick" ></Button>
                            </StackPanel>
                        </sdk:TreeViewItem.Header>
                    </sdk:TreeViewItem>
                </sdk:TreeViewItem.Items>
            </sdk:TreeViewItem>
        </sdk:TreeView>
        <ProgressBar Name="progressBar" Height="9" HorizontalAlignment="Left" Margin="216,82,0,0"  VerticalAlignment="Top" Width="139" Foreground="#FF3AB802" Grid.Column="2" Visibility="Collapsed" />
        <TextBox Name="textBox" Height="23" HorizontalAlignment="Left" Margin="146,68,0,0"  VerticalAlignment="Top" Width="66" Grid.Column="2" TextChanged="textBox_TextChanged" Visibility="Collapsed" />
        <ListBox Height="148" HorizontalAlignment="Left" Margin="0,152,0,0" Name="listBox1" VerticalAlignment="Top" Width="197" ItemsSource="{Binding}" Visibility="Collapsed" Grid.Column="2" SelectionChanged="listBox1_SelectionChanged"></ListBox>
        <ListBox Height="148" HorizontalAlignment="Right" Margin="0,154,160,0" Name="listBox2" VerticalAlignment="Top" Width="203" SelectionChanged="listBox2_SelectionChanged" Visibility="Collapsed" Grid.Column="2">
            <ListBoxItem />
            <ListBoxItem />
        </ListBox>
        <ComboBox Height="19" HorizontalAlignment="Left" Margin="13,204,0,0" Name="comboBox1" VerticalAlignment="Top" Width="104" SelectionChanged="comboBox1_SelectionChanged" Grid.ColumnSpan="2">
            <ComboBoxItem />
            <ComboBoxItem />
        </ComboBox>
    </Grid>
</UserControl>

据我保证,这个问题是由于比特转换器在 huffman 构造函数中调用函数 Func 转换器会产生问题。我想我需要以其他方式使用 Func 转换器


在你看来,我看不到你的代码有任何错误。在 silverlight 中,你无法像控制台或 WinForm 应用程序一样使用断点进行调试。 你能发送你的解决方案吗?然后我可以检查一下。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

泛型 在 C# 中不起作用,即使运行没有任何错误 的相关文章

  • 将图像文件从网址复制到本地文件夹?

    我有该图像的网址 例如 http testsite com web abc jpg http testsite com web abc jpg 我想将该 URL 复制到 c images 中的本地文件夹中 而且当我将该文件复制到文件夹中时
  • C# 中四舍五入到偶数

    我没有看到 Math Round 的预期结果 return Math Round 99 96535789 2 MidpointRounding ToEven returning 99 97 据我了解 MidpointRounding ToE
  • 静态类变量与外部变量相同,只是具有类作用域吗?

    在我看来 静态类变量与外部变量相同 因为你只需要declare它在static int x extern int x语句 并在其他地方实际定义它 通常在 cpp 文件中 静态类变量 h file class Foo static int x
  • 从 future 中检索值时的 SIGABRT

    我在使用 C 11 future 时遇到问题 当我打电话时wait or get 关于返回的未来std async 程序接收从mutex标头 可能是什么问题呢 如何修复它 我在 Linux 上使用 g 4 6 将以下代码粘贴到 ideone
  • 导出类时编译器错误

    我正在使用 Visual Studio 2013 但遇到了一个奇怪的问题 当我导出一个类时 它会抛出 尝试引用已删除的函数 错误 但是 当该类未导出时 它的行为会正确 让我举个例子 class Foo note the export cla
  • 如何在 Asp.net Gridview 列中添加复选框单击事件

    我在 asp 中有一个 gridview 其中我添加了第一列作为复选框列 现在我想选择此列并获取该行的 id 值 但我不知道该怎么做 这是我的 Aspx 代码
  • 单线程公寓问题

    从我的主窗体中 我调用以下命令来打开一个新窗体 MyForm sth new MyForm sth show 一切都很好 但是这个表单有一个组合框 当我将其 AutoCompleteMode 切换为建议和追加时 我在显示表单时遇到了这个异常
  • C# datagridview 列转入数组

    我正在用 C 构建一个程序 并在其中包含一个 datagridview 组件 datagridview 有固定数量的列 2 我想将其保存到两个单独的数组中 但行数确实发生了变化 我怎么能这样做呢 假设一个名为 dataGridView1 的
  • 手动将 ClientBase 集合类型从 Array[] 更改为 List<>

    我将自己的 WCF 代理与 Client Base 一起使用 我想做一些类似于 svc util 中的 ct 属性的操作 并告诉代理返回 List 集合类型 我不能使用 List 因为实体由 nhibernate 管理 所以我必须使用 IL
  • 正确使用“extern”关键字

    有一些来源 书籍 在线材料 解释了extern如下 extern int i declaration has extern int i 1 definition specified by the absence of extern 并且有支
  • 设计 Javascript 前端 <-> C++ 后端通信

    在我最近的将来 我将不得不制作一个具有 C 后端和 Web 前端的系统 要求 目前 我对此了解不多 我认为前端将触发数据传输 而不是后端 所以不需要类似 Comet 的东西 由于在该领域的经验可能很少 我非常感谢您对我所做的设计决策的评论
  • 不兼容的类型 - 是因为数组已经是指针吗?

    在下面的代码中 我创建一个基于书籍结构的对象 并让它保存多个 书籍 我设置的是一个数组 即定义 启动的对象 然而 每当我去测试我对指针的了解 实践有帮助 并尝试创建一个指向创建的对象的指针时 它都会给我错误 C Users Justin D
  • 相当于 C# 中 Java 的“ByteBuffer.putType()”

    我正在尝试通过从 Java 移植代码来格式化 C 中的字节数组 在 Java 中 使用方法 buf putInt value buf putShort buf putDouble 等等 但我不知道如何将其移植到 C 我尝试过 MemoryS
  • 从 C 线程调用 Python 代码

    我对从 C 或 C 线程调用 Python 代码时如何确保线程安全感到非常困惑 The Python 文档 http docs python org c api init html non python created threads似乎是
  • “int i=1,2,3”和“int i=(1,2,3)”之间的区别 - 使用逗号运算符的变量声明[重复]

    这个问题在这里已经有答案了 int i 1 2 3 int i 1 2 3 int i i 1 2 3 这些说法有什么区别 我无法找出任何具体原因 Statement 1 Result Compile error 运算符的优先级高于 运算符
  • #pragma pack(16) 和 #pragma pack(8) 的效果总是相同吗?

    我正在尝试使用来对齐数据成员 pragma pack n http msdn microsoft com en us library 2e70t5y1 28v vs 100 29 aspx 以下面为例 include
  • 如何获取 QIcon 的文件/资源​​路径

    假设我做了这样的事情 QIcon myIcon resources icon ico 我稍后如何确定该图标的路径 例如 QString path myIcon getPath 问题是 没有getPath 会员 我找不到类似的东西 但肯定有办
  • 如何设置 CMake 与 clang 交叉编译 Windows 上的 ARM 嵌入式系统?

    我正在尝试生成 Ninja makefile 以使用 Clang 为 ARM Cortex A5 CPU 交叉编译 C 项目 我为 CMake 创建了一个工具链文件 但似乎存在错误或缺少一些我无法找到的东西 当使用下面的工具链文件调用 CM
  • c# 模拟 IFormFile CopyToAsync() 方法

    我正在对一个异步函数进行单元测试 该函数将 IFormFile 列表转换为我自己的任意数据库文件类列表 将文件数据转换为字节数组的方法是 internal async Task
  • 无法使 Polly 超时策略覆盖 HttpClient 默认超时

    我正在使用 Polly 重试策略 并且正如预期的那样 在重试过程中HttpClient达到 100 秒超时 我尝试了几种不同的方法来合并 Polly 超时策略 将超时移至每次重试而不是总计 但 100 秒超时仍然会触发 我读过大约 5 个

随机推荐

  • 使用 LXML 和 Python 解析空白 XML 标签

    解析 XML 文档时的格式为
  • get.hist.quote() 是否仍然返回 source=yahoo Finance 的数据?

    HNY 正如主题行中的问题所暗示的那样 我在尝试使用 tseries 包函数时遇到错误get hist quote 任何人都可以阐明我错误地调用它 或者改变它的签名 功能吗 我昨天从工作中开始注意到这些错误 今天在我的家用机器上 同样的问题
  • iPhone 支持的音频文件格式 [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 iPhone 支持哪些音频文件格式 如果我想播放 2 小时的音频文件 我的应用程序中最好的音频文件格式是什么 Thanks mp3 为
  • 解读苹果崩溃报告

    正如他们所说 我的应用程序被 Appl App Store 审核团队拒绝 因为它在运行 iOS 5 1 1 的 iPhone 4S 和 iPad 第三代 上崩溃了 正如他们所说 我在运行 iOS 5 1 1 的 iPhone 4 上尝试了这
  • React 警告:列表中的每个子项都应该有一个唯一的“key”道具。在 render() 函数中[重复]

    这个问题在这里已经有答案了 我正在调用一个 API 端点 将其数据保存到一个状态 然后渲染它 它显示在浏览器中 但控制台上有警告 Warning Each child in a list should have a unique key p
  • 从字符串中删除元素后如何跟踪字符位置?

    假设我有以下字符串 my dog jumps and he is a very good dog 1234567890123456789012345678901234567890123456789012345678901 lt char p
  • 为什么我需要在单引号中转义美元符号?

    在 PowerShell 中 单引号中的字符串应该忽略其中的特殊字符 但是如果我使用的话为什么我需要转义美元符号 match Src SOMETHING Good Src Good returns string as is Src matc
  • SAML:即使用户有 IDP 会话,是否也可以强制用户完成登录过程

    在 SAML 中 即使用户有活动的 idp 会话 是否也可以强制用户每次都执行 idp 的登录过程 在这里举一个具体的例子 我们将我的应用程序命名为 SP 我使用 SSOCirecle 作为 idp 并使用 POST 和重定向 SP 发起
  • python上的并行执行和文件写入

    我有一个非常大的数据集 分布在 10 个大集群中 任务是对每个集群进行一些计算 并将结果逐行写入 附加 到 10 个文件中 其中每个文件包含与 10 个集群中的每个集群相对应的获得的结果 每个集群都可以独立计算 我想将代码并行化到十个CPU
  • 侧边栏折叠一秒钟并在页面加载时展开

    我有一个侧边栏 单击按钮即可展开或折叠 现在我已经成功地将它的状态存储在localStorage除了有一个小问题之外 它工作正常 当页面加载并且没有保存状态时localStorage 侧边栏collapses一瞬间expands Expan
  • 在 WCF 中,超时是否会导致通道故障?

    在 WCF 中 请求 响应操作超时是否会导致客户端通道出现故障 如果服务器发送响应超时 是否是服务器端通道出现故障 是的 超时会导致通道出现故障 而且总是只有one连接客户端和服务器的通道 服务器没有自己的通道 你基本上有 Client T
  • 为什么我的 Javascript 音频在刷新页面后不起作用?

    我的 javascript 中有一个音频对象并调用了 play 函数 当我第一次进入该页面或通过其他页面的链接进入该页面时 它工作正常 但是当我在带有音频的页面上并且只想刷新页面时 我会收到音频错误 Uncaught in promise
  • 按多个值过滤对象数组

    我希望能够通过多个搜索词过滤一个对象来创建一个新的对象数组 Example const arr city Atlanta state Georgia city Chicago state Illinois city Miami state
  • 从网站加载数据作为字符串(Android)

    我知道如何使用 WebView 在 Android 中加载网站内容 webview loadUrl http slashdot org 我怎样才能将网站的内容放入字符串变量中 在我想将此字符串解析为 XML 之后 但这是下一个问题 以下是对
  • 使用 javascript 函数渲染 HTML

    我有一个静态页面login and registration链接 我希望当用户点击时Login 它调用一个Javascript函数依次显示Login Form在同一页上 虽然我可以将整个 HTML 标签嵌入document write 但这
  • 正浮点数的正则表达式

    例如 10 0 1 1 23234 123 1230 000001 1 000 3 以及错误的例子 0001 2 12 1 01 2 3 EDIT 标准 JavaScript 正则表达式 在这里试试这个 1 9 d 0 d See it 在
  • Dotnet Core 3.1:如何使用具有文件绝对路径的 AddJsonFile?

    我有一个 dotnet 应用程序 我需要从两个相对路径 常规路径 中提取配置appsettings Json appsettings Development json 并且还可以从绝对路径 config appsettings json 我
  • 如何在特定时间执行循环

    我如何在指定的时间内执行特定的循环 Timeinsecond 600 int time 0 while Timeinsecond gt time do something here 我如何在这里设置时间变量 如果我可以使用 Timer 对象
  • 检查发件人电子邮件地址

    我的 Outlook 框中有一个 VBA 侦听器 用于在收到来自特定电子邮件的邮件时执行操作 问题是 如果我收到错误邮件 未送达电子邮件 那么我的条件是在不具有该属性的邮件上运行 因此我的方法崩溃 我也不知道主题是什么 有谁知道我是否可以测
  • 泛型 在 C# 中不起作用,即使运行没有任何错误

    我正在使用 Silverlight 5 VS 2010 创建一个 C Web 应用程序 首先 我创建了控制台应用程序 一切正常 但是当我在网络应用程序中执行此操作时会出现问题 即使在网络应用程序中 它对于特定的设置数据类型也能正常工作 例如