小编and*_*rea的帖子

不允许实体框架新事务,因为在会话中运行其他线程,多线程保存

我试着在DB上保存多线程processo的日志,但是我收到以下错误:不允许新事务,因为会话中还有其他线程在运行.

在每个胎面我都有这个功能:

 internal bool WriteTrace(IResult result, string message, byte type)
    {
        SPC_SENDING_TRACE trace = new SPC_SENDING_TRACE(
                        message,
                        Parent.currentLine.CD_LINE,
                        type,
                        Parent.currentUser.FULLNAME,
                        Parent.guid);
        Context.SPC_SENDING_TRACE.AddObject(trace);
        if (Context.SaveChanges(result) == false)
            return false;
        return true;

    }
Run Code Online (Sandbox Code Playgroud)

每个线程的Context都不同,但与DB的连接始终是相同的.

有没有办法解决这个问题?

谢谢Andrea

c# multithreading savechanges entity-framework-4

11
推荐指数
1
解决办法
3万
查看次数

WPF垂直网格探测器无法正常工作

我有一个垂直的网格分析器,但我得到一个水平的.这是我的XAML

<GroupBox Header="Phase Management">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="5"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="70*"/>
                <RowDefinition Height="30*"/>
            </Grid.RowDefinitions>

            <Button>Test column 0</Button>

            <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="#FFFFFF" ResizeBehavior="PreviousAndNext"/>

            <Button Grid.Column="2">Test column 2</Button>

        </Grid>
    </GroupBox>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

在网格中我有一个堆栈面板,一个数据网格和一些文本框.知道为什么我的行为有错吗?

c# wpf gridsplitter

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

流复位精度

我正在使用c ++来操作txt文件.我需要写一些具有一定精度的数字,所以我在做:

    ofstrem file;
    file.open(filename, ios::app);
    file.precision(6);
    file.setf(ios::fixed, ios::floafield);
    //writing number on the file.....
Run Code Online (Sandbox Code Playgroud)

现在我需要写其他东西,所以我需要重置精度.我该怎么做?

c++ precision ofstream

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

WPF访问列表视图代码隐藏的滚动查看器

我需要从代码隐藏访问列表视图的滚动查看器。这是我的列表视图的定义

<ListView Grid.Row="1" ItemsSource="{Binding Path=SpecList, UpdateSourceTrigger=PropertyChanged}"  
                            Name="mylistview"
                            ItemTemplate="{StaticResource SpecElementTemplate}"
                            Background="{StaticResource EnvLayout}"
                            ScrollViewer.HorizontalScrollBarVisibility="Visible"
                            ScrollViewer.VerticalScrollBarVisibility="Disabled"
                            ItemContainerStyle="{StaticResource MyStyle}"
                            BorderBrush="Blue"
                            BorderThickness="20"
                            Margin="-2">
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
</ListView>
Run Code Online (Sandbox Code Playgroud)

我怎样才能获得滚动查看器?

谢谢

安德烈亚

c# wpf listview code-behind scrollviewer

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

释放内存opencv

我已经发布了一些关于释放所有IplImage和所有CvMat结构的帖子CvMemStorage,但是我仍有一些内存问题.

我是否也将发布CvPoint,CvScalar,CvPoint*(排列3个CvPoints,我一定要释放的每个元素吗?)

如果我必须释放所有这些东西,我该怎么办?我没有找到任何功能.我在C/C++中使用OpenCV 2.1.

以下是我如何声明它们:

CvScalar b1;
CvScalar f;
float *data=(float*)resd->imageData; (need to release data)
CvPoint *point;
CvPoint pt;
CvPoint* ptsCorner=(CvPoint*) malloc(3*sizeof(ptsCorner[0]));   
Run Code Online (Sandbox Code Playgroud)

c c++ opencv memory-leaks

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

如何在写入到流的数字中添加填充零?

我正在尝试将数值写入与列对齐的文本文件中.我的代码看起来像这样:

ofstream file;
file.open("try.txt", ios::app);
file << num << "\t" << max << "\t" << mean << "\t << a << "\n";
Run Code Online (Sandbox Code Playgroud)

它有效,除非值没有相同的数字,否则它们不对齐.我想要的是以下内容:

1.234567  ->  1.234
1.234     ->  1.234
1.2       ->  1.200
Run Code Online (Sandbox Code Playgroud)

c++ padding ofstream

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

c#任务无法在没有睡眠的情况下工作

我在c#中使用Task在多线程中通过FTP发送文件.

这是我的函数(文件是一个字符串列表)

 Task<bool>[] result = new Task<bool>[file.Count];
        int j = 0;
        foreach (string f in file)
        {  
            result[j] = new Task<bool>(() => ftp.UploadFtp(f, "C:\\Prova\\" + f + ".txt", j));
            result[j].Start();
            j++;

            //System.Threading.Thread.Sleep(50);

        }
        Task.WaitAll(result, 10000);
Run Code Online (Sandbox Code Playgroud)

以及上传文件的功能

public static bool UploadFtp(string uploadFileName, string localFileName, int i)
    {
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://127.0.0.1/" + uploadFileName + ".txt");
        //settare il percorso per il file da uplodare
        //FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://desk.txt.it/");
        request.Method = WebRequestMethods.Ftp.UploadFile;

        request.Credentials = new NetworkCredential("ftp_admin", "");
        //request.Credentials = new NetworkCredential("avio", "avio_txt");
        try …
Run Code Online (Sandbox Code Playgroud)

c# multithreading task

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

Mongodb修补程序KB2731284

我安装了MongoDb windows server 2008 R2并且hotfix KB2731284没有安装,但我无法轻松重启服务器.

hotfix描述中,我收到此消息"您运行的应用程序使用该FlushViewOfFile()函数从分页内存池中清除内存映射文件." (见https://support.microsoft.com/en-us/kb/2731284)

我的问题是,什么时候FlushViewOfFile()调用函数?我的应用程序只是写入一个集合并从中获取数据.我是否有冒险行为的风险?

hotfix mongodb windows-server-2008-r2

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

功能睡眠无法解决

我正在使用eclipse而且我正在构建一个简单的程序,但是我得到一个错误,说函数sleep无法解析

#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
using namespace std;

int main() {
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    printf("ciao");
    sleep(20);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我不知道我是否需要其他库或其他东西.MinGW应该正确安装,所以我不知道

c++ eclipse sleep

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

在IplImage上写一个字符串

是否可以IplImage在C/C++中使用Opencv 2.1 编写字符串?

谢谢.

c c++ opencv

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