小编Yas*_*ser的帖子

在CUDA设备代码中使用std :: vector

问题是:有没有办法在Cuda内核中使用类"向量"?当我尝试时,我收到以下错误:

error : calling a host function("std::vector<int, std::allocator<int> > ::push_back") from a __device__/__global__ function not allowed
Run Code Online (Sandbox Code Playgroud)

那么有一种方法可以在全局部分使用向量吗?我最近尝试了以下内容:

  1. 创建一个新的Cuda项目
  2. 转到项目的属性
  3. 打开Cuda C/C++
  4. 转到设备
  5. 将"代码生成"中的值更改为此值:compute_20,sm_20

........之后我能够在我的Cuda内核中使用printf标准库函数.

有没有办法vector在内核代码中支持printf 的方式使用标准库类?这是在内核代码中使用printf的示例:

// this code only to count the 3s in an array using Cuda
//private_count is an array to hold every thread's result separately 

__global__ void countKernel(int *a, int length, int* private_count) 
{
    printf("%d\n",threadIdx.x);  //it's print the thread id and it's working

    // vector<int> y;
    //y.push_back(0); is there a possibility to do this? …
Run Code Online (Sandbox Code Playgroud)

cuda

37
推荐指数
4
解决办法
3万
查看次数

如何清除RichTextBox中的文本内容

获取RichTextBox中的文本后,我想清除文本.我怎样才能做到这一点?

TextRange txt = new TextRange(richtxtSNotice.Document.ContentStart, richtxtSNotice.Document.ContentEnd);
MessageBox.Show(txt.Text);
Run Code Online (Sandbox Code Playgroud)

c# wpf

37
推荐指数
3
解决办法
5万
查看次数

调用线程无法访问此对象,因为另一个线程拥有它.WPF

每当我刷新标签时,我都会收到此错误: 调用线程无法访问此对象,因为另一个线程拥有它.我试图调用,但它失败了.我正在使用WPF表格.

delegate void lostfocs(string st);
   private void imgPayment_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {

        Thread t = new Thread(modi);
        t.Start();
    }
 void modi()
    {
        try
        {
            label1.Content = "df";
        }
        catch
        {
            lostfocs ld = new lostfocs(up);
          //  ld.Invoke("df");
            object obj=new object();
            ld.Invoke("sdaf");
        }
    }
void up(string st)
    {
        label1.Content = st;
    }
Run Code Online (Sandbox Code Playgroud)

.net c# wpf multithreading dispatcher

22
推荐指数
3
解决办法
5万
查看次数

使用ItemsSource时,操作无效.使用ItemsControl.ItemsSource访问和修改元素

我是Binding和WPF的新手我最近学会了如何listBox使用Binding技术创建多列

 <ListView ItemsSource="{Binding Items}" Margin="306,70,22,17" MouseDoubleClick="listBoxSS_MouseDoubleClick" Name="listBoxSS" >           
    <ListView.View>
            <GridView>
                <GridView.Columns>
                    <GridViewColumn Header="first_name " Width="100" DisplayMemberBinding="{Binding Path=First_name}" />
                    <GridViewColumn Header="last_name" Width="100" DisplayMemberBinding="{Binding Path=Last_name}" />
                    <GridViewColumn Header="phone_number" Width="100" DisplayMemberBinding="{Binding Path=Phones[0]}" />
                    <GridViewColumn Header="notes" Width="100" DisplayMemberBinding="{Binding Path=Notes}" />
                </GridView.Columns>
            </GridView>
        </ListView.View>
    </ListView>
Run Code Online (Sandbox Code Playgroud)

这是代码:

List<Student> arr = search.students();
        listBoxSS.ItemsSource = arr;
Run Code Online (Sandbox Code Playgroud)

但问题是当我尝试使用添加或删除项目或清除时

 listBoxSS.Items.Clear();
Run Code Online (Sandbox Code Playgroud)

我需要一个使用项目源的示例或我可以添加或删除项目或清除列表的方式.

编辑:

<ListView ItemsSource="{Binding Items}" Margin="306,70,22,17" MouseDoubleClick="listBoxSS_MouseDoubleClick" Name="listBoxSS" >
    <ListView.View>
        <GridView>
            <GridView.Columns>
                <GridViewColumn Header="first_name " Width="100" DisplayMemberBinding="{Binding Path=First_name}" />
                <GridViewColumn Header="last_name" Width="100" DisplayMemberBinding="{Binding Path=Last_name}" />
                <GridViewColumn Header="phone_number" Width="100" …
Run Code Online (Sandbox Code Playgroud)

c# xml wpf listview multiple-columns

21
推荐指数
4
解决办法
5万
查看次数

将项绑定到ListBox多列

我正在尝试将我的数据添加到多个列ListBox中,我做到了但是我在尝试从列表框中检索数据时遇到了一个难题.有没有办法将对象而不是文本放入listBox行?

<ListView Name="listBox1" ItemsSource="{Binding Items}" Margin="28,28,68,67" FlowDirection="RightToLeft" MouseDoubleClick="listBox1_MouseDoubleClick">
        <ListView Name="listBox1" ItemsSource="{Binding Items}" Margin="28,28,68,67" FlowDirection="RightToLeft" MouseDoubleClick="listBox1_MouseDoubleClick">
        <ListView.View>
            <GridView>
                <GridView.Columns>
                    <GridViewColumn Header="a" Width="100" DisplayMemberBinding="{Binding Path=ID}" />
                    <GridViewColumn Header="b" Width="100" DisplayMemberBinding="{Binding Path=Name}" />
                    <GridViewColumn Header="c" Width="100" DisplayMemberBinding="{Binding Path=F}" />
                </GridView.Columns>
            </GridView>
        </ListView.View>
    </ListView>
</Grid>
Run Code Online (Sandbox Code Playgroud)

这是代码

 public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }
    public sealed class MyListBoxItem
    {
        public string Field1 { get; set; }
        public string Field2 { get; set; }
        public string Field3 { get; set; } …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml listbox multiple-columns

2
推荐指数
1
解决办法
4439
查看次数

SQL UPDATE不适用于外语(阿拉伯语)

UPDATE给出 ????updater字段是用阿拉伯语写的,这是我的查询:

UPDATE  students 
SET first_name = '?????' , last_name = '????? ??????' , 
    father_name = '????? ??????' , mother_name = '', 
    birth_date = '1/1/1990 12:00:00 AM' , education_level = '' , 
    address = '' , notes = '' 
WHERE student_id = 33
Run Code Online (Sandbox Code Playgroud)

以下是更新的结果:

student_id  first_name  last_name   mother_name     father_name   birth_date    
33           ?????      ?????          ??????       ???????????   1990-01-01
Run Code Online (Sandbox Code Playgroud)

//答案很棒,谢谢大家,另一个问题是我在C#程序中使用了这种UPDATE语法

command.CommandText = "UPDATE  students SET " +
        "first_name = " + "'" + first_name + "'" + " , last_name = " …
Run Code Online (Sandbox Code Playgroud)

sql sql-server-2008

1
推荐指数
1
解决办法
3318
查看次数